Skip to Main Content
PHP in a Nutshell
book

PHP in a Nutshell

by Paul Hudson
October 2005
Intermediate to advanced content levelIntermediate to advanced
372 pages
11h 35m
English
O'Reilly Media, Inc.
Content preview from PHP in a Nutshell

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, you can pass data from page to page by using hidden form elements, storing answers in session values, or storing answers in a database.

Of the three, you are most likely to find using hidden form elements the easiest to program and the easiest to debug. As long as you are using POST, data size will not be a problem, and the advantage is that you can view the HTML source code at any time to see if things are working as planned. Of course, that also means that hackers can view the source code (and make changes to it), so you should really only resort to hidden fields if you can't use sessions for some reason.

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.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP Cookbook

PHP Cookbook

Eric A. Mann
Programming PHP

Programming PHP

Rasmus Lerdorf, Kevin Tatroe
Learning PHP

Learning PHP

David Sklar

Publisher Resources

ISBN: 0596100671Errata Page