Multi Page form submission

Hi folks,

I have an HTML form that is having multiple pages.user completes the first page, then click “Step 2” and then “Step 3” and so on. now, my question is, when the user completes the first page and click “step 2”, what is the best way to keep the first page data?

in other words, when the user completes the first page and before go to the send page, should i add the first page data directly to the database or just pass it to second page using POST / GET or else write it to an xml ?

Please advise.

I guess it depends. IMHO if the data needs to be complete for it to be of any use then there’s little sense in involving database INSERTs and passing it along in hidden inputs would work. But if you want the users to be able to pick up where they left off upon returning, or if the partial data is useful in some way, then keeping it in a database would be a good idea

Have you considered staying on the one page and using JS to create the illusion of multiple pages?

Like @Mittineague said, it really depends upon your specific scenario. Do you want the ability to have a user half complete their form, and then come back to it at a later date to finish it? If so, then saving it in a database after each page has been completed would be the best way to go.

On the other hand, if you want the form to be completed there and then, then storing the submitted form data as $_SESSION data would be the better approach to avoid inserting incomplete information in your database. You could also propagate the previous page(s) data via hidden fields, though that data could easily be lost if the user accidentally closes their browser or clicks off of the web page (which can easily happen), and so I’d probably favour session data instead.

Thanks guys for the valuable advises.