User Manual
General | Control Panel | Form Features | ||
---|---|---|---|---|
Multi-page Forms
Index
If you use JavaScript for handling form error checking and error messages, the method described in the Multi-Page Forms article may be a good choice. Otherwise, follow the instructions below.
Whichever multi-page form method is used, any form upload fields must be on the last form page.
The first step is to create a table setup (See the Create Table Setup link in this control panel.) Any required or email fields listed in the Form Field Restrictions section of the table setup page need to have the form page specified.
Get the name="MySQL_table_key" hidden field value with the Get Setup Info link in this control panel. Make a note of the table key value.
How Multi-Page Forms Differ From 1-Page Forms
Multi-page forms differ in 4 ways. Make the pages of the form and then incorporate the differences.
Here is a list of the 4 items that differ from regular forms for the first page, middle pages, and last page of a multi-page form. Only the first item is optional. The rest are required.
Item 1 —
Error Messages.
(This item is optional.) Code can be inserted to print error messages related to the submission of the previous form page.
Additional content can conditionally be printed with error messages. The form on this page can conditionally be excluded when error messages are printed. See the
This item is optional because it is not part of the form. Instead, it is an information section for the form user.
First page: Not applicable.
Middle and last pages: The code to print any available error messages is:
<?php echo($ErrorMessage); ?>
Item 2 —
The hidden field for specifying the table key.
The hidden field that provides the table key number to Master Form .PHP is put somewhere within the form. Immediately below the <form...> tag is good.
All pages of a multi-page form have the same table key number. But the first page and middle pages have a different form field name for containing the number.
First and middle pages (assuming table key value="1"):
<input type="hidden" name="Interim_MySQL_table_key" value="1">
Last page (assuming table key value="1"):
<input type="hidden" name="MySQL_table_key" value="1">
Item 3 —
Bringing previous form page values forward.
First page: Not applicable.
Middle and last pages: Insert this somewhere within the form. Immediately below the <form...> tag is a good place.
<?php echo( BringPreviousFieldsForward() ); ?>
If the values of any of the previous form fields shall not be brought forward, do this:
Between the parenthesis of the function call, and between quotation marks, type except= followed by a comma-separated list of the form fields not to be brought forward. Example:
<?php echo( BringPreviousFieldsForward("except=extraneous,submitter") ); ?>
Item 4 —
The URL in the JavaScript below the form's cancel </form> tag.
First and middle pages: The URL of the next form page in the sequence.
Last page: The URL of the confirmation/thank-you page (same as a one-page form).
An Example 3-Page Form
The example multi-page form has one text form field per page and a submit button. In practice, individual form pages may have as many fields as required.
Example form page 1 —
<form id="myform" method="post" enctype="multipart/form-data" action="<?php echo($_SERVER['PHP_SELF']); ?>"> <input type="hidden" name="Interim_MySQL_table_key" value="2"> Name: <input type="text" id="name" name="name"> <input type="submit" name="submitter" value="Go to page 2"> </form> <script type="text/javascript"> var formTagID = "myform"; var confirmationPage = "page2.php"; document.getElementById(formTagID).action=confirmationPage; </script>
Example form page 2 —
The middle page(s). In practice, there may be any number of middle pages.
<?php echo($ErrorMessage); ?> <form id="myform" method="post" enctype="multipart/form-data" action="<?php echo($_SERVER['PHP_SELF']); ?>"> <?php echo( BringPreviousFieldsForward("except=submitter") ); ?> <input type="hidden" name="Interim_MySQL_table_key" value="2"> Email: <input type="text" id="email" name="email"> <input type="submit" name="submitter" value="Go to page 3"> </form> <script type="text/javascript"> var formTagID = "myform"; var confirmationPage = "page3.php"; document.getElementById(formTagID).action=confirmationPage; </script>
Example form page 3 —
The last page.
<?php echo($ErrorMessage); ?> <form id="myform" method="post" enctype="multipart/form-data" action="<?php echo($_SERVER['PHP_SELF']); ?>"> <?php echo( BringPreviousFieldsForward("except=submitter") ); ?> <input type="hidden" name="MySQL_table_key" value="2"> Telephone: <input type="text" id="phone" name="phone"> <input type="submit" name="submitter" value="Submit final page"> </form> <script type="text/javascript"> var formTagID = "myform"; var confirmationPage = "thank-you.php"; document.getElementById(formTagID).action=confirmationPage; </script>
The first page of the example multi-page forms collects the form user's name. The page submits to the second form page.
The second form page collects the email address. The form submits to the third and last form page.
The third and last form page collects the telephone number and submits to a
Master Form PHP V3, version 3.0
Copyright 2010, 2011 Bontrager Connection, LLC
Copyright 2011-2013, 2015, 2017, 2020 Will Bontrager Software LLC