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? Link to comment https://forums.phpfreaks.com/topic/99319-forms-multiple-pages-dont-want-to-submit-till-last-page/ 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? Link to comment https://forums.phpfreaks.com/topic/99319-forms-multiple-pages-dont-want-to-submit-till-last-page/#findComment-508164 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 Link to comment https://forums.phpfreaks.com/topic/99319-forms-multiple-pages-dont-want-to-submit-till-last-page/#findComment-508167 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']); Link to comment https://forums.phpfreaks.com/topic/99319-forms-multiple-pages-dont-want-to-submit-till-last-page/#findComment-508171 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 Link to comment https://forums.phpfreaks.com/topic/99319-forms-multiple-pages-dont-want-to-submit-till-last-page/#findComment-508176 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? Link to comment https://forums.phpfreaks.com/topic/99319-forms-multiple-pages-dont-want-to-submit-till-last-page/#findComment-508179 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; Link to comment https://forums.phpfreaks.com/topic/99319-forms-multiple-pages-dont-want-to-submit-till-last-page/#findComment-508183 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) Link to comment https://forums.phpfreaks.com/topic/99319-forms-multiple-pages-dont-want-to-submit-till-last-page/#findComment-508200 Share on other sites More sharing options...
JustinK101 Posted April 3, 2008 Author Share Posted April 3, 2008 I can wait bigDogCms, thanks! Link to comment https://forums.phpfreaks.com/topic/99319-forms-multiple-pages-dont-want-to-submit-till-last-page/#findComment-508230 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). Link to comment https://forums.phpfreaks.com/topic/99319-forms-multiple-pages-dont-want-to-submit-till-last-page/#findComment-508240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.