First off this is a bad idea from the beginning, at least it looks like it. By using a get and a form, regardless if it's generated by javascript or not, you are inviting your users to set their own price. Unless, or perhaps even if this is all on a ssl, there could be problems of that nature. You might want to set the price on the receiving page or even further along the chain.
That said, I'm not sure what you want to do with this information on the receiving page. But this sort of thing works and can probably be adapted to your purposes:
PHP Code:
$pattern = '/^(item_name_|item_number_|quanity_|amount_|on0_|os0_)\d+$/';
foreach ($_GET as $key => $value){
if(preg_match ($pattern, $key, $matches)){
echo "$matches[0] is: $value<br>";
}
}
It's here:
PHP Code:
echo "$matches[0] is: $value<br>";
that you could adapt it. $matches[0] will be item_name_1 or 2, etc. or quantity_1 or 2, etc, or whatever, and $value will be its value. You could create a new array before hand and add to it in that section, or do other things, even multuple things with the data using as many lines as is required.
Getting back to the above code as is though - say this receiving page is get_stuff.php and you navigate to it with:
Code:
get_stuff.php?item_name_1=bob&item_number_1=1&quantity_1=3&amount_1=$3.25&on0_1=whatever&os0_1=something&item_name_3=sally&item_number_3=3&quantity_3=2&amount_3=$4.75&on0_3=what&os0_3=somethingelse
The output would be:
item_name_1 is: bob
item_number_1 is: 1
amount_1 is: $3.25
on0_1 is: whatever
os0_1 is: something
item_name_3 is: sally
item_number_3 is: 3
amount_3 is: $4.75
on0_3 is: what
os0_3 is: somethingelse
Or maybe all you need is the number (#) in item_name_# and could go from there using if( isset($_GET['item_number_' . $x]) . . . type filters to get the other info if available. The code for that would be a little different and probably more cumbersome though.
Bookmarks