Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

http post and key value pairs

Status
Not open for further replies.

aprinc

Programmer
Jan 19, 2003
2
DK
I have to collect data from HTTP post. Data is send in key value pairs. I have to store value in databse.
How HTTP post is send ( how it looks when sending )?
<input type=text name=&quot;f_name&quot; value=&quot;$first_name => ADI&quot;> or ?

How to collect values? I know name of the key ($first_name) just need to collect value.Can not use function foreach()
because I use php3.

example of key value pairs:
$first_name => John
$last_name => Smith

Thanks in advance
 
Why don't you just use
Code:
<input type=text name=&quot;first_name&quot; value=&quot;ADI&quot;>
instead of
Code:
<input type=text name=&quot;f_name&quot; value=&quot;$first_name => ADI&quot;>
? This way you would be able to use the $first_name variable in your script and it would have the value ADI. //Daniel
 
Because iBill sending me those key value pairs.
 
So if you run..

foreach ($_POST as $key=>$value) {
echo $key.&quot; => &quot;.$value.&quot;<BR>\n&quot;;
}

You'll get something like...

f_name => $first_name => John
l_name => $last_name => Smith
...

Right?

If so, then...

Something like...
foreach ($_POST as $value) {
$temp = split(&quot;=>&quot;, $value);
$value[$temp[0]] = $temp[1];
}

Think I got that right...

You might want to strip off the $ too... though I left it because I believe there's a function which will convert the array that function generates directly to variables if they stay in that format... but I'm drawing a blank on its name.

-Rob
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top