By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,965 Members | 1,702 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,965 IT Pros & Developers. It's quick & easy.

Forms spanning over multiple pages

P: 18
I am working on a small site, whose main purpose is to gather lots of user registration data and use that for their need. Now since the required data is quite heavy, I will be splitting my forms across 3 or even 4 pages.

How should I keep track of the data being submitted on the earlier pages? I can keep the data in a temporary table in the database using MySQL, and purge all of that across the main tables once the final page is done, but I guess that is a bit risky. Another option is to set a cookie to hold all that information. Maintaining a session is another one, though I do not wish to bloat my session variable.

How do I check my fields for validation? Should I include both Javascript as well as PHP validation?

Any help would be very welcome. Thanks.
May 10 '07 #1
Share this Question
Share on Google+
2 Replies

P: 93
One way to carry data from one form to another is to take the data from the first form and put it into hidden form fields in the 2nd form:
Your first form:
Enter your name: <input type="text" name="name">

Your first PHP script (which is also your 2nd page with the 2nd form)
<input type="hidden" name="name" value="<?php print stripslashes($_POST['name']); ?>">
And then have all the other form filelds for the 2nd form.

I suppose another option would be to put the data into your db as you collect it (if that's where it's going eventually anyway). The problem with this is that if your user doesn't complete all of the forms then you get a database with half complete info in it, so you'd need a way of periodically checking the database for useless data and ditching it.

As for validation, php is more secure because javascript validation is done on the user's computer and therefore they could mess with it if they were feeling naughty! The disadvantage of php validation is that is puts more strain on your server. It depends on whether the validation is there to stop people from hacking you or just to stop innocent user errors. And that depends on what your php script does with the data. If you're putting it into a database then you need to be more careful than if you're just say printing it out on the page.
May 10 '07 #2

Expert 5K+
P: 5,058
I personally would put them into the Session array. It's by far the easiest and quickest solution.

If your puting the data back into the form as was suggested, your posting the same data over and over again.
Putting them into a temporary database table is way to much trouble for this kind of stuff, and in my opinion, databases should only be used for data you want to keep, not as a temp storage.

As for validating the data. I personally avoid using Javascript where possible, so I'd use PHP, it's aslo much safer seeing as anybody can read your javascript and that is just asking for trouble.
May 10 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.