rhartman Posted November 15, 2010 Share Posted November 15, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/218755-post-array-into-php-variables/ Share on other sites More sharing options...
ManiacDan Posted November 15, 2010 Share Posted November 15, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/218755-post-array-into-php-variables/#findComment-1134589 Share on other sites More sharing options...
AbraCadaver Posted November 15, 2010 Share Posted November 15, 2010 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... Quote Link to comment https://forums.phpfreaks.com/topic/218755-post-array-into-php-variables/#findComment-1134593 Share on other sites More sharing options...
ManiacDan Posted November 15, 2010 Share Posted November 15, 2010 // page2 echo '<input type="hidden" name="first_page" value="' . serialize($_POST) .'">'; That won't work if the array is very large, and it will be a waste of bandwidth. Simply using the session is the best solution. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/218755-post-array-into-php-variables/#findComment-1134603 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.