You want to use a form that displays more than one page and preserves data from one page to the next. For example, your form is for a survey that has too many questions to put them all on one page.
Use session tracking to store form information for each stage as well as a variable to keep track of what stage to display. Example 9-21 displays a two-page form and then the collected results.
Making a multipage form
At the beginning of each stage in Example 9-21, all the submitted form variables are copied into $_SESSION. This makes them available on subsequent requests, including the code that runs in stage 3, which displays everything that's been saved.
PHP's sessions are perfect for this kind of task since all of the data in a session is stored on the server. This keeps each request small'no need to resubmit stuff that's been entered on a previous stage'and reduces the validation overhead. You only have to validate each piece of submitted data when it's submitted.
9.11.4. See Also
Recipe 11.1 for information about session handling.