0

I have an order form with multiple steps. Form submission is carried out using AJAX. Once a step is completed and submitted the related script validates it and returns a success message. Using JQuery the completed step is hidden and the next step is made visible. The last step of the form shows a order review, this is where i need to show the user inputs that have been validated.

I thought of setting a session variable containing the validated input, after each step, that can then be read in the final step and displayed to the user.

Here's a diagram showing how form should work.

How the Order form works

Is there a better way of doing this? Thank you!

nad
  • 1,068
  • 6
  • 16

1 Answers1

1

If it is a single page web application, why can't you just store it in the client-side?

I wouldn't recommend sessions as you may get unexpected behavior with them, although they could "work". Your question is a big vague as there isn't really a "better" way of doing things, since it depends on your situation. Based on the information you have given to me, I would store the validated information in the database. That way the user can go back and access the completed steps no matter what (closes the browser, logs out, etc.), I think it gives more flexibility with what you can do with the information and is more reliable than a session. As well sessions could face problems (example is relative vs absolute path where the domain could change from no www to wwww. I talk about this here)

You could store all the "steps" as a singleton in form_id, and then relate them across tables via. the form_id, each table representing a full page step and containing the information for the page (if it's not a single web page application). This way you can later re-access it as long as it is not deleted by yourself (and I'd assume the average user does not have MySQL root privileges)

Community
  • 1
  • 1
q.Then
  • 2,743
  • 1
  • 21
  • 31
  • Thanks for the feedback! I got it working by adding the validated inputs into a database table. :) – nad Sep 09 '15 at 06:15