Jump to content

Post Array into PHP Variables?


rhartman
 Share

Recommended Posts

I have a form that is producing the following :

 

Array ( [formID] => 3154008308 [q1_applicationDate] => Array ( [month] => 11 [day] => 15 [year] => 2010 ) [q4_fullName4] => Array ( [first] => TOM [last] => STONE ) [q5_email] => TSTONE@YAHOO.COM [q6_address6] => Array ( [addr_line1] => 325 E LINCOLN [addr_line2] => [city] => GENESEE [state] => NY [postal] => 33256 [country] => United States ) [q38_selectProvider38] => Sprint [q39_selectPlan] => Individual [website] => [simple_spc] => 3154008308-3154008308 )

 

HOW do I automatically get each item above into it's own PHP variable?  The page that receives this Array is the second page of a 3 or 4 page form.  I need to send the above information on through the remainder of the form??

 

Would appreciate any help!  Thanks!

 

 

 

 

Link to comment
Share on other sites

There's a number of things at work here.

 

1)  Each of these is already in its own addressable space:  $_POST['formID'] is 3154008308

 

2)  If you want to have data persist between pages, use the session.

 

3)  If you want to store a big list of variables in the session, you would want to make them an array.  They are already an array, so breaking them into their own variables would be counter productive.

 

-Dan

Link to comment
Share on other sites

Several ways.  You can shove it in the session or use a hidden input:

 

// page2
session_start();
$_SESSION['first_page'] = $_POST;

 

or

 

// page2
echo '<input type="hidden" name="first_page" value="' . serialize($_POST) .'">';

 

Pick one of these and do it on each page.  Then on the last page you can access either:

 

$_SESSION['first_page'], $_SESSION['second_page'] etc...

 

or

 

$_POST['first_page'], $_POST['second_page'] etc...

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.