JustinK101 Posted April 3, 2008 Share Posted April 3, 2008 I have a sign up form, which has four pages, with each page having a form and fields. I want to pass each pages form data on to the next page until finally the fourth page is filled out, then at that pull all the form data from each page and store into a mysql database. How is this possible? What is the most elegant way of doing this? Quote Link to comment Share on other sites More sharing options...
JustinK101 Posted April 3, 2008 Author Share Posted April 3, 2008 Humm I just thought, can I store the global array $_POST of each form page in a session, then pull all the 3 session $_POST values out on the fourth page? Quote Link to comment Share on other sites More sharing options...
devstudio Posted April 3, 2008 Share Posted April 3, 2008 I always find it easiest to make sure all form data is passed as an array.  <input type="text" name="formData[name]">  Elegant is a matter of opinion. Dump each pages form data ($_GET[formData or $_POST[formData]) into a session and append to that session with each subsequent page, on the last page insert from the session. Serialize each pages formdata and place that serialized string into a hidden field. Append to the string on subsequent pages. Unserialize on the final page and perform your operations.   Best, Nathan  Quote Link to comment Share on other sites More sharing options...
JustinK101 Posted April 3, 2008 Author Share Posted April 3, 2008 Seems like storing the $_POST of each page in a session is the best way? Does it make sense to do: Â # Page 1 Â $_SESSION['page_1'] = serialize($_POST); Â # Page 2 Â $_SESSION['page_2'] = serialize($_POST); Â # Page 3 Â $_SESSION['page_3'] = serialize($_POST); Â # Page 4 Â $page_1 = unserialize($_SESSION['page_1']); $page_2 = unserialize($_SESSION['page_2']); $page_3 = unserialize($_SESSION['page_3']); Quote Link to comment Share on other sites More sharing options...
devstudio Posted April 3, 2008 Share Posted April 3, 2008 I think that makes fine sense.  As long as $_POST is only what you want. Of course you can unset() anything out of $_POST before serializing.  Keep in mind these types of User Interfaces is what AJAX is all about.  Best, Nathan Quote Link to comment Share on other sites More sharing options...
JustinK101 Posted April 3, 2008 Author Share Posted April 3, 2008 Do I even have serialze the $_POST array or can I simply stick it into the session without serializing? Quote Link to comment Share on other sites More sharing options...
devstudio Posted April 3, 2008 Share Posted April 3, 2008 Serialization certainly isn't required. Â But to keep some sanity, I would recommend building a multidimensional array. Â // Assign Page 1 $_SESSION['page_1'] = $_POST; // Assign Page 2 $_SESSION['page_2'] = $_POST; // Assign Page 3 $_SESSION['page_3'] = $_POST; Quote Link to comment Share on other sites More sharing options...
Bigdogcms Posted April 3, 2008 Share Posted April 3, 2008 use javascript to set sessions just use onblur or onfocus to submit the info, if u can wait i can try to write u a script in the morning(too tired now) Quote Link to comment Share on other sites More sharing options...
JustinK101 Posted April 3, 2008 Author Share Posted April 3, 2008 I can wait bigDogCms, thanks! Quote Link to comment Share on other sites More sharing options...
lordfrikk Posted April 3, 2008 Share Posted April 3, 2008 Just a note - when you decide to use JS based solution, make sure it will work for those, who have JS turned off as well (known as (graceful) degradation - http://webtips.dan.info/graceful.html). Quote Link to comment 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.