Configuring the first form page
From the API's viewpoint, the first page in your form is special. It lets the script know that a new user has just arrived and to start logging their form submission as they progress through the form. Add this to the very top of your page (before the opening html tag and doctype), and make a few minor modifications to it, as discussed below:
- The path to the api.php file has to be updated for your server
- Change "submit_button_name_attribute" to the name attribute of your form submit button
- Change "next_page.php" to the SECOND page in your multi-page form. This is where the user gets directed to after submitting this page.
- If your form contains file fields, add one more parameter to the $params array: the last file_data row.
Next, make sure your form tag has the following action and method attributes:
Note there's no action
attribute - that makes the form submit the information to itself.
The processFormSubmission()
method will take care of redirecting to the next page. One of the nice
things about posting the submission to itself is that if later on, you choose to add server-side validation
(see this tutorial), it's much easier to handle the
errors on the same page.
With regard to the form's post attribute, if you want to use method="GET", that's fine - just change the PHP line in the top of the from:
to: