views:

23

answers:

1

I'm developing a system (in PHP) that will take in a string of text (from email, initially) and need to determine the beginning and end of a section of the text that contains name=value pairs of data, and parse that section so that the name=value pairs can be processed into a form submission. I am looking for ideas on what to use as delimiters, what algorithm to use for the processing (push the whole thing through a regular expression? process it line by line?), functions to use for parsing, etc.

I will also need to somehow validate the data before processing it, allow for multiple field names to be used for the same fields (coming from different systems) and allow for optional fields. Are there other things I should be concerned about as well?

As an example, I might receive an email like this:

--
Dear Brain,

Please open this ticket.

System: Windows Issue
Severity: Complete Work Stoppage
Short Description: Narf!
Long Description: I don't know what the h$#* happened!

Oh, and yeah, can you do it tonight?
Pinky

--

We currently have a web-based form where users can manually open a ticket. I want to link into that system and submit an HTML form to the same process. I'm not looking for a programming solution, just some "best practice" ideas.

Thanks!

A: 

In my opinion there are 3 steps to do it right.

1. Get the data from the input and put it in to a variable;

2. Clean the user input from bad data such as html or equivalent.

3. Is the Implementation of the beginning and ending of the string Function you wrote about. I would use in that case a Pear package.

streetparade
1. That's a little obvious.2. I already mentioned data validation.3. Huh? (and installing additional packages is probably not an option)
machinatus