Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Page Form

Status
Not open for further replies.

RSedlacek

Programmer
Oct 5, 1998
59
US
I am designing a site which will have users register, log in and then fill out a questionnaire form which will be on multiple pages. When a user clicks on each submit button I want the form to save the data to the same record in a database table and then proceed to load the next part of the form on the next page. I don't want to pass the data from page to page and then save to the database on the last page of the form.

Are there any tips, tricks or other things I need to be aware of or watch out for when coding this?
 
not really any tricks, its easier than passing the values from page to page.

on page one
insert the data,
insert into usersTable (username, password) values ('#form.userName#', '#form.password#')
<cflocation url = "page2.cfm?userName=#form.userName">


on the rest of the pages use the unique id to update the first record (probably the user name)
update table set address = '#form.address#', phoneNumber = '#form.phoneNumber#' where userName = '#url.userName#'
<cflocation url = "page3.cfm?userName=#url.userName#>

You could also submit right to page2 from page1 and to page3 from page2. that would eliminate the cflocations but would make serverside validation harder.




A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Bad idea, I've tried it several times. I have a situation like that here at work. I used multiple forms and would insert/update the info after each page instead of saving it till the end. I wound up having to do a lot of database work because someone would lose power, or they would start the form and go to lunch and it had timed out when they came back, or they would click the submit button but decide to go back and try again...etc...

You cannot anticipate how people will use your application. No matter how simple or how striaght forward it is, or how much training they've had on it, someone will always be screwing it up. That's a fact.

If you're going to build it so that it saves the data after every form, you will have to make it so that the users can come back to it at any point and pick up where they left off. Go ahead and plan on that from the start.

My advice would be, just pass the info from form to form until you submit it at the end. Here's an easy way to do it (thanks to webmigit). Just put this at the beginning of every form after your first one, and it will take all values from the previous form and store them as hidden form fields in your new form.
Code:
<cfoutput>
  <cfloop list="#form.fieldnames#" index="f">
    <input type="hidden" value="#jsstringformat(FORM[f])#" name="#f#">
  </cfloop>
</cfoutput>



Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher
 
that's probably a good point.

what you COULD do if you were dead set on saving after every form is to either put the data in a seperate "signup" table.

if they loose where they were they can choose to continue signup and "log back in". but the log in only takes them to the part of the sign up form they left off at. once they finish the signup put the data in the live table and delete the signup record.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Ecobb,

I see what you are saying. That's the same reason I wanted to save data after each part of the form...to prevent lost data and work from a user that loses power, goes to lunch, times out, gets interupted, etc. It's a fairly long questionnaire and I wanted to protect the data along the way. I was planning on having another form that users could come back, log in and make modifications later. That would take care of part of the problem you mentioned.

Now you've got me concerned about other possible problems like, clicking submit and then clicking the back button to try again.

I may have to rethink this. What I am trying to do may not be feasible or practical.

Does anyone else have any suggestions or experience with this?

Randy
 
bombboy has a good idea with the "signup" table. Go ahead and submit everything after every form, then take that info and put it in the "real" table when they finish. If they don't finish, you could also give them an option to "resume questionnaire or delete and start over". He also has a good idea with the cflocations. That would help prevent people from backing up and resubmitting. I use that a good bit in my form processing.

If it's long and chances are that most of your users aren't going to fill out the whole form at one time, then I think you're on the right track.



Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher
 
just curious. Who cares if the click back and resubmit. The only problem that would cause is if the record was being inserted. (page1 to page2) an easy way around that is to check for an existing username. You'd have to do that anyway to ensure proper security. on the update pages, if they click back and resubmit it simply reupdates the old record with new values, exactly what the user intended.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
I usually store all the form fields into cookies /sessions as the user moves along the multi-page form

That way, if there is a mistake, you have the abilty to make sure the user can go back and fix it without having to fill in every field again.

page one is sent to page 2 for validatation
page 2 is sent ot page 3 etc.

As each page is complete, you can even have the option to go back to any previously completed pages to make edits.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top