Merge all post data with comma separators?
Posted: Wed May 07, 2008 9:27 am
Situation: User posts large amounts of data that will be used as CSS values (later on) to the server.
Goal: I'd like to merge all post the data in to a single string, separate each piece of post with a comma, and then check the data using regex for some simple patterns. The order does not necessarily matter but that is the way I am initially approaching it. Once complete this single string will be set to a cookie. To my site's visitor this information will be used in a second style sheet that overrides the primary style sheet which will use PHP to later split data in to an array and construct the secondary stylesheet. (You guys are going to drool when you see my new site editor.
)
The data construct is fairly simple and repetitive...
1.) User selects a selector (range 0-24).
2.) User selects a property (range 0-3).
3.) User selects a value (three characters 0-f || six characters 0-f || 'none' || 'transparent').
The input names are based on the select[] index.
'ce' + selector[] + property[] = value.
Examples...
Selector 9, property 4 = 'ce83' (value is changed to selected value)
Selector 10, property 3 = 'ce92'
Selector 11, property 2 = 'ce101'
Selector 12, property 1 = 'ce110'
Keep in mind that the select index starts at 0 so...
you think 1 and it's 0...
you think 2 and it's 1...
you think 3 and the index is 2 etc.
This is how the data is structured being sent to the server. Maybe it could be handled by the client but we can't trust the client can we? I am open to the idea of merging the data to a single string at the client though I'd still have to run regex checks at the server regardless.
Any way to reduce server load I use a hidden input to tell the server what form is being used. In my mind at least this skips PHP from executing all of the code I will/we'll be working on here if the request isn't a post method and if it is will only execute in the following condition...
My Questions essentially barrel down to...
1.) Would it be better to merge all the data in to a single string at the server or the client? By default I have been planning to do this at the server.
2.) I already run regex at the client though would it be easier to do regex on a single string or a temporary array? For example the value 'none' would be allowed on every second of four sets of values while color (0-f) values of three or six characters in length or the value 'transparent' would be allowed via the regex every first, third, and fourth value out of every set of four.
I'm very interested in your opinions to help me create a Titan instead of a Frankenstein.
Goal: I'd like to merge all post the data in to a single string, separate each piece of post with a comma, and then check the data using regex for some simple patterns. The order does not necessarily matter but that is the way I am initially approaching it. Once complete this single string will be set to a cookie. To my site's visitor this information will be used in a second style sheet that overrides the primary style sheet which will use PHP to later split data in to an array and construct the secondary stylesheet. (You guys are going to drool when you see my new site editor.
The data construct is fairly simple and repetitive...
1.) User selects a selector (range 0-24).
2.) User selects a property (range 0-3).
3.) User selects a value (three characters 0-f || six characters 0-f || 'none' || 'transparent').
The input names are based on the select[] index.
'ce' + selector[] + property[] = value.
Examples...
Selector 9, property 4 = 'ce83' (value is changed to selected value)
Selector 10, property 3 = 'ce92'
Selector 11, property 2 = 'ce101'
Selector 12, property 1 = 'ce110'
Keep in mind that the select index starts at 0 so...
you think 1 and it's 0...
you think 2 and it's 1...
you think 3 and the index is 2 etc.
This is how the data is structured being sent to the server. Maybe it could be handled by the client but we can't trust the client can we? I am open to the idea of merging the data to a single string at the client though I'd still have to run regex checks at the server regardless.
Any way to reduce server load I use a hidden input to tell the server what form is being used. In my mind at least this skips PHP from executing all of the code I will/we'll be working on here if the request isn't a post method and if it is will only execute in the following condition...
Code: Select all
if ($_POST['formis'] == "site_editor")
{
}1.) Would it be better to merge all the data in to a single string at the server or the client? By default I have been planning to do this at the server.
2.) I already run regex at the client though would it be easier to do regex on a single string or a temporary array? For example the value 'none' would be allowed on every second of four sets of values while color (0-f) values of three or six characters in length or the value 'transparent' would be allowed via the regex every first, third, and fourth value out of every set of four.
I'm very interested in your opinions to help me create a Titan instead of a Frankenstein.