See: http://html.about.com/library/weekly/aa072699.htm
Multi-Page Forms
The trick to creating multiple page forms is to use HIDDEN fields. The hidden input tag (discussed in part 2) is a valuable tool for developers who want to create forms with many pages, and not write the data until the end.
The trick to it is to make sure that all your form entry fields have different names. Then, when you use a hidden field on the second and subsequent pages, you can use the same name as you gave it on the first page.
The steps:
- Collect the form data as you normally would (using INPUT, SELECT, and TEXTAREA tags). For this example, we'll input a text tag with the name first_name, and the value Jennifer.
- When the submit button is pressed, have your CGI do any processing required on the data, and then write page 2 using the CGI (print or printf in Perl and C).
- Within the second (and subsequent) page of the form, have your CGI write the currently submitted data as the values of hidden tags. There was only one field input, and so my CGI would write: <input type="hidden" name="first_name" value="Jennifer">. In a Perl script, this might look something like:
my $first_name = $in{'first_name'};
print "<input type=\"hidden\" name=\"first_name\" value=\"$first_name\">";