Hudzilla.org - the homepage of Paul Hudson
Contents > HTML Forms Wish List | Report Bug | About Me ]

7.5     Splitting forms across pages

This is NOT the latest copy of this book; click here for the latest version.

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.





<< 7.4.5 Handling our form   7.6 Files sent through forms >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
REKHAKNR@REDIFFMAIL.COM - 05 Sep 2008

HOW TO HANDLE DYNAMIC LIST BOXES USING PHP
Once i change the value in first list box ,automatically changes the value in second list box

rcsreddy@yahoo.com - 05 Sep 2008

how to use 2 submit options in 2 forms in the same page?

A PHP User - 05 Sep 2008

how to use two submit option in 2 different forms in a same page?

A PHP User - 05 Sep 2008

If used carelessly, hidden form fields can represent a security issue. You shouldn't store data such as passwords, prices, etc., in hidden fields--these should be transmitted directly to the server (preferrably via a secure connection) and persisted in the session or a database.

A PHP User - 05 Sep 2008

The Hidden type is meant to transfer information across additional pages.

For example, if you have a button "Delete" that goes to a confirmation page, you'll want to transfer information like the article id properly once "yes" is clicked.

A PHP User - 05 Sep 2008

I honestly have no idea what this page is talking about.

what is this hidden type suppose to do? Need to show it in example not just codes itself because i am very confused where to place this.



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is nine plus zero?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow