7.5 Splitting forms across pagesThis 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:
-
Use hidden form elements
-
Store answers in session values
-
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.
|
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!
|