Splitting forms across pages

Very often it is necessary to split up one long form into several smaller forms, placed across several pages. When this is the case, there are three possible tactics you can take:

  1. Use hidden form elements

  2. Store answers in session values

  3. Store answers in a database

Of the three, you are most likely to find option #1 the easiest to program and the easiest to debug. As long as you are using HTTP POST, data size will not be a problem, and the advantage to use hidden form elements is that you can view the HTML source code at any time to see if things are working as planned.

If our existing form was part one of a larger set of forms, we would need to append the following HTML to the bottom of part two of the forms so that the values are carried over to part three:

<input type="hidden" name="Name" value="<?php print $_GET['Name']; ?>">
<input type="hidden" name="Password" value="<?php print $_GET['Password']; ?>">

You'd need to have all the others there also, but it works in the same way so there is no point repeating them all here.

 

Next chapter: Files sent through forms >>

Previous chapter: Handling our form

Jump to:

 

Home: Table of Contents

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar