Click to See Complete Forum and Search --> : Multi-page form
focus310
05-06-2007, 05:43 PM
Hello:
I have an application form consisting of nine pages. They would like to have the application to be completed on the website.
Rather than having one long scrolling screen of questions, is it possible to have questions from page 1 appear, then click a link Next Page link for page 2 and show those questions, then click a Next Page link for page 3 questions, etc.?
If so, how can I accomplish this?
Thank you for the assistance.
yintercept
05-06-2007, 07:16 PM
Yes. It is possible.
The amateurish way to do this is to carry the data from one form to the next in hidden fields. If everything goes well, when you get to the ninth page all of the data will be in hidden variables. The final page would then save to the database.
The easy way almost always fails because people want to go back and correct things. Also, if they close their browser, all is lost.
A better way to go about a task like this is to create a SQL Table with columns for all of the questions. Let's call this table Work_Area. Each page would add more data to the Work_Area table. The Work_Area table would effectively track of the user's location in the application process. That way they could go back and change a question with losing their place.
The first page would start the application by assigning the id. The key should be random, not sequential. Hackers know how to exploit sequential keys.
I would save the key in a cookie. You might even display the user the key and have them write it down for future reference.
Each following page in the session would add more data to the table. When the user gets to the end of the application, Work_Area would have all the data that the user entered. The final step would verify that the table is complete then send the data from Work_Table into the main Application Table.
This is basically the way a shopping cart works. A shopping cart is a work area for an online order.
Here is a quick review of the flow: You have a large table called Work_Area that has all of the columns of the application.
The user fills out page one. The first page would INSERT a row in the table and issue a random key for the session. You would put the key in a cookie for quick reference.
The form pops up with page two. They fill out more information. Your script would UPDATE Work_Area with this information, then shows page three.
They fill out page three, hit submit. Your page updates the next columns in the table and delivers page four.
Your user realizes they made a mistake on page two. They go back and change page two. You program would UPDATE page two columns again. It would see that page three was complete and display page 4.
What I've done in the past is have a status bar at the top of the form. The status bar shows the numbers from 1 to 9 in a control bar. Each time the user finished a page, the number for that page would become active. That way the user could go back and forth filling out pages.
When all of the columns of the Work_Area are complete, the form would display a verify and submit button. If you were really classy, you would show the user a page with all of the data they entered for a final error check.
Pressing submit would copy the data from the work table to the main database.
focus310
05-07-2007, 07:08 AM
Hi,
Thanks for the reply. Could I accomplish the same thing using sessions? I would pass session variables from page to page, have a final check, and then post to a table.
apg88
05-07-2007, 07:15 AM
I've done it with sessions and it works flawlessly.
It is probably the easiest to accomplish and requires no database.
focus310
05-07-2007, 07:23 AM
Hi,
With the sessions, would I be able to have the person go back to previous pages if need be without losing information?
I was on a website where they used sessions and I had to go back one page and I received a message saying the web page has expired and to click the Refresh button. Well, I clicked the Refresh button, everything I entered for that page was blank.
What do I do to avoid this from happening with my pages?
Thanks for the help.
apg88
05-07-2007, 08:36 AM
Have an actual back button on the page, that way when the user clicks, it will refresh the page they go back to.
If the user just clicks the browsers back button, the page will not reload.
focus310
05-07-2007, 08:43 AM
Thanks for the input. I will give the back button a try.