WannaLearn
Programmer
I'm having some trouble creating a session.userid. No matter what I do, its not working.
This is what I have:
Application.cfm
<cfapplication name="abc123" ClientManagement="No" SessionManagement="Yes" SessionTimeout="#CreateTimeSpan(0,0,30,0)#" SetClientCookies="Yes">
<cfset ds = "abc">
<cfset frmname = "xxx">
<cfinclude template="../../../../123.cfm">
<!--- Check to see if the session variable exists, if not set it. --->
<CFPARAM name="Session.UserID" default="">
<CFIF IsDefined("Session.UserID") EQUAL "No">
<cfset User_ID = Session.UserID>
</CFIF>
page1.cfm
<html>
<body>
<form name"<cfoutput>#frmname#</cfoutput>" action="page2.cfm" method="post">
<table width="330" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="321"><br>Enter your zipcode: <br>
<table width="290" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" width="50%">
<input type="text" name="f6" size="7" maxlength="5" value="">
<input type="hidden" name="ffid" value="1">
<input type="submit" name="SubmitButton" value="Next Page">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
page2.cfm
<cfset ffid = "#form.ffid#">
<!--- Check to see if the session variable exists, if not redirect them to the login page --->
<CFIF IsDefined("Session.UserID") EQUAL "No">
<cfset User_ID = Session.UserID>
<cfelse>
<cfset User_ID = 99999>
</CFIF>
<form name="<cfoutput>#frmname#</cfoutput>" action="page3.cfm" method="post">
<table cellpadding=0 width="385" align=center
border=0 cellspacing="0" id="form">
<tbody>
<tr valign="MIDDLE">
<td align=right height="28">First name: </td>
<td height="28"> <input name="f1" id="f1" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">Last name: </td>
<td width="59%" height="28"> <input name="f2" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">Email: </td>
<td width="59%" height="28"> <input size=30 name="f3" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">Address: </td>
<td width="59%" height="28"> <input size=30 name="f4" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">City: </td>
<td width="59%" height="28"> <input name="f5" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">Zip Code: </td>
<td width="59%" height="28"> <input maxlength=5 size=10
name="f6" value="<cfoutput>#f6#</cfoutput>"> </td>
</tr>
<tr valign="TOP" align="CENTER">
<td colspan="2" height=""><br> <input type=checkbox value=1 name="f7" checked>
I agre</td>
</tr>
<tr valign="MIDDLE" align="CENTER">
<td colspan="2" height="40">
<input type="hidden" name="ffid" value="1">
<input type=Submit value="Next!" name="SubmitButton">
</td>
</tr>
</tbody>
</table>
</form>
page3.cfm
<cfif isdefined("FORM.ffid")>
<cfif isdefined("FORM.fieldnames")>
<!--- Create empty list of processed variables --->
<cfset fp = "">
<!--- Loop through fieldnames --->
<cfloop index="f_el" list="#FORM.fieldnames#">
<!--- Fix for Orbit Text area( loops through all variables regardless --->
<cfif f_el is not "f999999999">
<!--- Try to find current element in list --->
<cfif f_el IS "ffid" OR f_el IS "SubmitButton">
<cfset fp = ListAppend(fp, f_el)>
</cfif>
<cfif ListFind(fp, f_el) IS 0>
<!--- Make fully qualified copy of it (to prevent acessing the wrong field type) --->
<cfset f_el_qualified = f_el>
<!--- Only record field if form is submited --->
<cfif IsDefined("form.SubmitButton") OR IsDefined("form.SubmitImage.x")>
<!--- Set value for variable outside cfquery to avoid single quote issue --->
<cfset FAV=Evaluate(f_el_qualified)>
<cfquery name="rec" datasource="#ds#">
INSERT INTO Table1 (HFA, User_ID, FFID, fid)
VALUES ('#FAV#', #User_ID#, #ffid#,#removechars(f_el,1,3)#)
</cfquery>
</cfif>
<!--- And add it to the processed list --->
<cfset fp = ListAppend(fp, f_el)>
</cfif>
</cfif>
</cfloop>
</cfif>
</cfif>
<html>
<body>
Thanks.
</body>
</html>
Now, I can't figure out what i'm doing wrong. How do you create a user_id, and then pass it along the process until the user entry has been inserted into the database?
I keep getting blank as my user_id. So, how do I create a session.user_id?
Thanks.
This is what I have:
Application.cfm
<cfapplication name="abc123" ClientManagement="No" SessionManagement="Yes" SessionTimeout="#CreateTimeSpan(0,0,30,0)#" SetClientCookies="Yes">
<cfset ds = "abc">
<cfset frmname = "xxx">
<cfinclude template="../../../../123.cfm">
<!--- Check to see if the session variable exists, if not set it. --->
<CFPARAM name="Session.UserID" default="">
<CFIF IsDefined("Session.UserID") EQUAL "No">
<cfset User_ID = Session.UserID>
</CFIF>
page1.cfm
<html>
<body>
<form name"<cfoutput>#frmname#</cfoutput>" action="page2.cfm" method="post">
<table width="330" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="321"><br>Enter your zipcode: <br>
<table width="290" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" width="50%">
<input type="text" name="f6" size="7" maxlength="5" value="">
<input type="hidden" name="ffid" value="1">
<input type="submit" name="SubmitButton" value="Next Page">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
page2.cfm
<cfset ffid = "#form.ffid#">
<!--- Check to see if the session variable exists, if not redirect them to the login page --->
<CFIF IsDefined("Session.UserID") EQUAL "No">
<cfset User_ID = Session.UserID>
<cfelse>
<cfset User_ID = 99999>
</CFIF>
<form name="<cfoutput>#frmname#</cfoutput>" action="page3.cfm" method="post">
<table cellpadding=0 width="385" align=center
border=0 cellspacing="0" id="form">
<tbody>
<tr valign="MIDDLE">
<td align=right height="28">First name: </td>
<td height="28"> <input name="f1" id="f1" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">Last name: </td>
<td width="59%" height="28"> <input name="f2" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">Email: </td>
<td width="59%" height="28"> <input size=30 name="f3" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">Address: </td>
<td width="59%" height="28"> <input size=30 name="f4" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">City: </td>
<td width="59%" height="28"> <input name="f5" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">Zip Code: </td>
<td width="59%" height="28"> <input maxlength=5 size=10
name="f6" value="<cfoutput>#f6#</cfoutput>"> </td>
</tr>
<tr valign="TOP" align="CENTER">
<td colspan="2" height=""><br> <input type=checkbox value=1 name="f7" checked>
I agre</td>
</tr>
<tr valign="MIDDLE" align="CENTER">
<td colspan="2" height="40">
<input type="hidden" name="ffid" value="1">
<input type=Submit value="Next!" name="SubmitButton">
</td>
</tr>
</tbody>
</table>
</form>
page3.cfm
<cfif isdefined("FORM.ffid")>
<cfif isdefined("FORM.fieldnames")>
<!--- Create empty list of processed variables --->
<cfset fp = "">
<!--- Loop through fieldnames --->
<cfloop index="f_el" list="#FORM.fieldnames#">
<!--- Fix for Orbit Text area( loops through all variables regardless --->
<cfif f_el is not "f999999999">
<!--- Try to find current element in list --->
<cfif f_el IS "ffid" OR f_el IS "SubmitButton">
<cfset fp = ListAppend(fp, f_el)>
</cfif>
<cfif ListFind(fp, f_el) IS 0>
<!--- Make fully qualified copy of it (to prevent acessing the wrong field type) --->
<cfset f_el_qualified = f_el>
<!--- Only record field if form is submited --->
<cfif IsDefined("form.SubmitButton") OR IsDefined("form.SubmitImage.x")>
<!--- Set value for variable outside cfquery to avoid single quote issue --->
<cfset FAV=Evaluate(f_el_qualified)>
<cfquery name="rec" datasource="#ds#">
INSERT INTO Table1 (HFA, User_ID, FFID, fid)
VALUES ('#FAV#', #User_ID#, #ffid#,#removechars(f_el,1,3)#)
</cfquery>
</cfif>
<!--- And add it to the processed list --->
<cfset fp = ListAppend(fp, f_el)>
</cfif>
</cfif>
</cfloop>
</cfif>
</cfif>
<html>
<body>
Thanks.
</body>
</html>
Now, I can't figure out what i'm doing wrong. How do you create a user_id, and then pass it along the process until the user entry has been inserted into the database?
I keep getting blank as my user_id. So, how do I create a session.user_id?
Thanks.