Forum Moderators: coopster

Message Too Old, No Replies

Collecting $ POST over and over again?

Not multiple selects, but multiple fields

         

salewit

2:44 am on Jul 22, 2007 (gmt 0)

10+ Year Member



I have a form that gathers this data:

Billing First Name (name=bfirst)
Billing Last Name (name=blast)
address1, address2, city, state, zip, country, email, phone, shipping name, shipping address1, etc. About 30 inputs.

When I go to take in these variables, is there any easier way of bringing in the variables other than:

$bfirst = $_POST["bfirst"];
$blast = $_POST["blast"];

through the whole list?

Thx

LBmtb

8:16 am on Jul 22, 2007 (gmt 0)

10+ Year Member



You can do what you're doing now or do arrays by saying something like name="address[]" to collect multiple addresses.

eelixduppy

7:14 am on Jul 23, 2007 (gmt 0)



You might also be able to get away with using extract [php.net]() however it depends on your situation. Go with the solution above first if you can.

dreamcatcher

12:17 pm on Jul 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want to quickly assign your vars, you can loop through the post array and use variable variables.

foreach ($_POST AS $data)
{
$$data = $data;
}

Or just access the post vars directly without assigning to variables:

echo $_POST['bfirst'];
echo $_POST['blast']

dc