isedeasy Posted January 18, 2010 Share Posted January 18, 2010 Hi Everyone, I have a form that is quite long and I would like to separate it into stages. I would like some help on how I should go about this, not any code help but I would like to know the best method for transferring variables from stage to stage. I want to have all stages on one page and I will need to validate before moving to the next stage, only at the last stage should the mySQL insert be called. I was thinking of posting variables from the previous stages into hidden inputs and then re validating on the last stage or maybe using sessions. I was hoping there is a better/more efficient method that I have overlooked. Cheers for any pointers Quote Link to comment https://forums.phpfreaks.com/topic/188894-multiple-stage-form/ Share on other sites More sharing options...
deansatch Posted January 18, 2010 Share Posted January 18, 2010 How about using ajax and submitting the details of stage 1 on blur() of the final input for that stage. Something along the lines of how a username field would check for availability when moving to the password field etc... btw- I assume by having all stages on one page you are meaning that all the form fields will be available in one go? Otherwise just store details in a session Quote Link to comment https://forums.phpfreaks.com/topic/188894-multiple-stage-form/#findComment-997322 Share on other sites More sharing options...
PFMaBiSmAd Posted January 18, 2010 Share Posted January 18, 2010 only at the last stage should the mySQL insert be called Why? Why not put the data gathered at each step into the database (after you validate it), marked with a 'pending' status? If this form is as long you hint, why not store the data persistently on the server so that if something should happen to cause a problem that would loose any data in a hidden form field or in a session (such as a battery dying, the Internet connection gets broken, the browser is accidentally closed, the cat chews through the power cord...), that you don't require the visitor to reenter everything from the start? Quote Link to comment https://forums.phpfreaks.com/topic/188894-multiple-stage-form/#findComment-997323 Share on other sites More sharing options...
isedeasy Posted January 18, 2010 Author Share Posted January 18, 2010 That makes complete sense I can check to see if the user has a form pending and ask them if they want to continue or start from scratch. Quote Link to comment https://forums.phpfreaks.com/topic/188894-multiple-stage-form/#findComment-997328 Share on other sites More sharing options...
PFMaBiSmAd Posted January 18, 2010 Share Posted January 18, 2010 You will also find that your overall code will be simpler and more constant for each step of the form. Quote Link to comment https://forums.phpfreaks.com/topic/188894-multiple-stage-form/#findComment-997331 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.