Copy link to clipboard
Copied
I have a multi-page form, which is basic. The form's first page is to post a new person's fist and last name. The second page is for the person's current address. Of course, there's more objects/database fields than this, but I need page 1 to go to page 2 smoothly, and without much pause. Page 2 is the exact same person as page 1. The ID for the person is created on page 1, somehow.
How do I get the 2nd page form to know it's the same person on page 1? Do I use call_number =form.ID or ID=ID or what? Does the form on each page have be the same name? Does the ACTION have to be the name of the next page in the form (page2), or the name of the page which submits the data?
PAGE 1 "The Name"
<CFQUERY DATASOURCE="people" NAME="nw">
SELECT *
FROM people_table;
</CFQUERY>
<HTML>
<HEAD>
<TITLE>Add an Entry.</TITLE>
</HEAD>
<BODY>
<TABLE>
<TR>
<TD>
<FORM
ACTION="p_in.cfm"
METHOD="post"
NAME="formNewPersonPage1">
<INPUT
TYPE="hidden"
NAME="peopleID">
<INPUT
TYPE="hidden"
NAME="entry_date_time"
VALUE="now()">
Your First Name:
<INPUT
TYPE="text"
NAME="people_nm_f"
SIZE="30"
id="First name">
<P>
Your Last Name:
<INPUT
TYPE="text"
NAME="gb_entry_nm_l"
SIZE="30"
id="Last name">
<BR>
<P>
Checkbox if Male:
<INPUT
TYPE="checkbox"
NAME="people_nm_male_x">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
____________________________________________________
PAGE 2 "The Current Address"
<CFQUERY DATASOURCE="people" NAME="nw">
SELECT *
FROM people_table
WHERE formNewPersonPage1.peopleID=ID;
</CFQUERY>
<HTML>
<HEAD>
<TITLE>Add an Entry Page 2</TITLE>
</HEAD>
<BODY>
<TABLE>
<TR>
<TD>
<FORM
ACTION="p_in.cfm"
METHOD="post"
NAME="formNewPersonPage2">
Your Street #:
<INPUT
TYPE="text"
NAME="peopleStreetNbr"
SIZE="30">
Your City:
<INPUT
TYPE="text"
NAME="peopleCity"
SIZE="30">
<BR>
Your State:
<P>
<INPUT
TYPE="text"
NAME="peopleState"
SIZE="30">
<P>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
Copy link to clipboard
Copied
For a start, I would recommend cfform and cfinput in place of form and input. Then you wouldn't have to use cfoutput, for example.
On page 1, the visitor could be anyone. You don't yet know him. So there is no need to run a query on the page. Also, I would give the hidden field, peopleID, the value session.sessionID.
The action page of the form in page 1 should be the URL of page 2. To verify on page 2 whether you're dealing with the same person, compare the values of form.peopleID and session.sessionID. ( Remember that form.peopleID holds the value of session.sessionID in the context of page 1).
Each form should have a distinct name, id and action. I expected to see a query like this one on the second form page
<CFQUERY DATASOURCE="people" NAME="nw">
SELECT *
FROM people_table
WHERE fname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.first_name#">
AND lname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.last_name#">
</CFQUERY>