Forms spanning over multiple pages

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • guile
    New Member
    • Apr 2007
    • 18

    #1

    Forms spanning over multiple pages

    Hi,
    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.
  • adamalton
    New Member
    • Feb 2007
    • 93

    #2
    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.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      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.

      Comment

      Working...