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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem trying to confirm password. 1

Status
Not open for further replies.

DrDan2

Technical User
Nov 22, 2002
24
GB
I have a form that will post to a CF page. The form has two fields to fill in with names 'Password and Password2.'
I have the following code in my CF page:

<CFIF #Password# NEQ #Password2# OR
LEN(TRIM(Form.Password)LTE 0)>
<CFSET Error1=&quot;Please Check Password.<br>&quot;>
</CFIF>

But I keep getting an error message saying that the variable password is undefined. Why? Any help would be great.. thanks.
 
looks okay to me, i bet you have a typo somewhere :)

why not include the following at the top of your page

<CFPARAM NAME=&quot;form.Password&quot; DEFAULT=&quot;&quot;>
<CFPARAM NAME=&quot;form.Password2&quot; DEFAULT=&quot;&quot;>

then i believe your logic will still work the way it stands

rudy
 
Thanks. I'll have to double, triple check it then. I had CFSET, but CFPARAM would be better . Thanks.
 
Ok. Here goes. There's gonna be a lot of text here, and I can understand if nobody wants to look through but I can't figure out what's wrong so I thought I'd just post everything. What I'm trying to achive is to have th CF 2nd CF page to check the data entered in the form to see if the essential info is there, if not it will return to the form and explain what is wrong. here is the form part from the first page which will post to another CF page.
-------------------------------------------------------
<FORM METHOD=&quot;Post&quot; ACTION=&quot;NewMemberDetails.cfm&quot; ENCTYPE=&quot;Multipart/Form-Data&quot;>

<TABLE BORDER=0>
<TR><td>Contact Name:</td><td><INPUT TYPE=&quot;Text&quot; Name=&quot;ContactName&quot;></td></TR>
<TR><td>Your Business' Name:</td><td><INPUT TYPE=&quot;Text&quot; Name=&quot;OrgName&quot;>*</td></TR>
<TR><td>Organisation:</td><td><SELECT Name=&quot;Organisation&quot;>
<OPTION VALUE=&quot;PADI&quot;>PADI</OPTION>
<OPTION VALUE=&quot;BSAC&quot;>BSAC</OPTION>
<OPTION VALUE=&quot;Other&quot;>Other. Please Give Details</Option>
</SELECT>*</td></TR>
<TR><td VALIGN=Top>Brief Summary:</td><td><TEXTAREA ROWS=3 NAME=&quot;Description&quot;></TEXTAREA></td></TR>
<TR><td>City:</td><td><INPUT TYPE=&quot;Text&quot; NAME=&quot;City&quot;>*</td></TR>
<TR><td>Address 1:</td><td><INPUT TYPE=&quot;Text&quot; Name=&quot;Address1&quot;></td></TR>
<TR><td>Address 2:</td><td><INPUT TYPE=&quot;Text&quot; Name=&quot;Address2&quot;></td></TR>
<TR><td>Post/Zip code:</td><td><INPUT TYPE=&quot;Text&quot; Name=&quot;PostCode&quot;></td></TR>
<TR><td>Country:</td><td><InPUT TYPE=&quot;Text&quot; Name=&quot;Country&quot;>*</td></TR>
<TR><td>Tel:</td><td><INPUT TYPE=&quot;Text&quot; Name=&quot;Tel&quot;></td></TR>
<TR><td>Fax:</td><td><INPUT TPYE=&quot;Text&quot; Name=&quot;Fax&quot;></td></TR>
<TR><td>E-Mail:</td><td><INPUT TYPE=&quot;Text&quot; Name=&quot;Email&quot;>*</td></TR>
<TR><td>WebSite:</td><td><INPUT TYPE=&quot;Text&quot; Name=&quot;Website&quot;></td></TR>
<TR><td>Facilites:</td><td><INPUT TYPE=&quot;Text&quot; Name=&quot;Facilities&quot;></td></TR>
<TR><td>Password: </td><td><INPUT TYPE=&quot;Password&quot; Name=&quot;Password&quot;>*</td></TR>
<TR><td>Confirm Password </td><td><INPUT TYPE=&quot;Password&quot; Name=&quot;Password2&quot;>*</td></TR>

<TR><td VALIGN=top>Dive Logo:</td><td><INPUT TYPE=&quot;File&quot; NAME=&quot;Logo&quot;><br>
<I>Please keep it smaller than 10k.</I></td></TR>
<TR><TD COLSPAN=2 ALIGN=Center>
<br><INPUT Type=&quot;Submit&quot; VALUE=&quot;Send It!&quot;>&nbsp;&nbsp;
<INPUT TYPE=&quot;Reset&quot; VALUE=&quot;Reset Details&quot;>
</td></TR>
</TABLE><p>

</FORM>
-------------------------------------

This is the full code the CF page:

<HTML>

<!---Validation Code--->

<CFIF Password NEQ Password2 OR
LEN(TRIM(Form.Password)LTE 0)>
<CFSET Error1=&quot;Please Check Password.<br>&quot;>
</CFIF>

<CFIF LEN(FindNoCase(&quot;@&quot;,Form.Email)LTE 0) OR
LEN(FindNoCase(&quot;.&quot;,Form.Email)LTE 0) OR
LEN(Trim(Form.Email)LT 8)>
<CFSET Error2=&quot;Invalid E-Mail address.<br>&quot;>
</CFIF>

<CFIF LEN(Trim(Form.Country)LTE 0)>
<CFSET Error3=&quot;You did not specify Country.<br>&quot;>
</CFIF>

<CFIF LEN(Trim(Form.City)LTE 0)>
<CFSET Error4=&quot;You did not specify City.<br>&quot;>
</CFIF>

<CFIF LEN(Trim(Form.OrgName)LTE 0)>
<CFSET Error5=&quot;You did not specify your company name.<br>&quot;>
</CFIF>

<CFSET TotalError=&quot;#Error1# #Error2# #Error3# #Error4# #Error5#&quot;>

<!---End Validation. Continue in Head of page.--->



<CFIF Logo is not &quot;&quot;>
<CFFILE ACTION=&quot;Upload&quot; FILEFIELD=&quot;Form.Logo&quot;
Destination=&quot;C:\CFusionMX\ NAMECONFLICT=&quot;Overwrite&quot; ACCEPT= &quot;image/gif, image/jpg, image/pjpeg, image/jpeg&quot;>
<CFSET NewLogo = File.Clientfile>

<CFQUERY DATASOURCE=&quot;DiveSchools&quot; Name=&quot;NewImage&quot;>
INSERT INTO DiveData(Logo, ContactName, OrgName, Organisation, Description, City, Address1,
Address2, PostCode, Country, Tel, Fax, Email, Website, Facilities)
VALUES ('#NewLogo#','#ContactName#','#OrgName#','#Organisation#','#Description#','#City#',
'#Address1#','#Address2#','#PostCode#','#Country#','#Tel#','#Fax#','#Email#',
'#Website#','#Facilities#')
</CFQUERY>

<CFQUERY DATASOURCE=&quot;DiveSchools&quot; Name=&quot;LogoQuery&quot;>
Select *
From DiveData
Where Logo='#NewLogo#' AND OrgName='#OrgName#'
</CFQUERY>

<CFELSE>

<CFQUERY DATASOURCE=&quot;DiveSchools&quot; Name=&quot;NewImage&quot;>
INSERT INTO DiveData(Logo, ContactName, OrgName, Organisation, Description, City, Address1,
Address2, PostCode, Country, Tel, Fax, Email, Website, Facilities)
VALUES ('NoLogo.jpg', '#ContactName#','#OrgName#','#Organisation#','#Description#','#City#',
'#Address1#','#Address2#','#PostCode#','#Country#','#Tel#','#Fax#','#Email#',
'#Website#','#Facilities#')
</CFQUERY>

<CFSET NewLogo = &quot;NoLogo.jpg&quot;>

<CFQUERY DATASOURCE=&quot;DiveSchools&quot; Name=&quot;LogoQuery&quot;>
Select *
From DiveData
Where OrgName='#OrgName#' AND Email='#Email#'
</CFQUERY>
</CFIF>


<HEAD>
<TITLE>AAAARGH</TITLE>

<CFIF LEN(#TotalError#)GT 5>
<META HTTP-EQUIV=&quot;Refresh&quot; Content= URL=&quot;NewMember.cfm?TotalError=<CFOUTPUT>'#TotalError#'</CFOUTPUT>>
</CFIF>
</HEAD>


<BODY>

<CFOUTPUT QUERY=&quot;LogoQuery&quot;>

<CENTER><H2>Welcome #ContactName#<br></H2>
and thankyou for helping help in building what will hopefully become the worlds<br>
most detailed Dive Database.<p>

Your ID Number is DC#ID_CODE#. Please quote this number if you need to
contact me.<p><HR></CENTER>

<B>Your Current Details are as follows:</B><br>
<TABLE BORDER=0 Width=75%>
<TR><td WIDTH=80>Contact Name:</td><td VALIGN=Top>#ContactName#</td>
<td ROWSPAN=14 ALIGN=Center VALIGN=Top>
<IMG SRC=&quot;C:\CFusionMX\ Border=0><br>
Please ensure your logo is small and doesn't exceed 10 kilobytes.<br>
Thank you again for your time. Dive Happy. :)
</td></TR>
<TR><td VALIGN=Top>Business Name:</td><td VALIGN=Top>#OrgName#</td></TR>
<TR><td VALIGN=Top>Organisation:</td><td VALIGN=Top>#Organisation#</td></TR>
<TR><td VALIGN=Top>Summary of Business:</td><td VALIGN=Top>#Description#</td></TR>
<TR><td VALIGN=Top>City:</td><td VALIGN=Top>#City#</td></TR>
<TR><td VALIGN=Top>Address 1:</td><td VALIGN=Top>#Address1#</td></TR>
<TR><td VALIGN=Top>Address 2:</td><td VALIGN=Top>#Address2#</td></TR>
<TR><td VALIGN=Top>Post/Zip Code:</td VALIGN=Top><td>#Postcode#</td></TR>
<TR><td VALIGN=Top>Country:</td><td VALIGN=Top>#Country#</td></TR>
<TR><td VALIGN=Top>Tel:</td><td VALIGN=Top>#Tel#</td></TR>
<TR><td VALIGN=Top>Fax:</td><td VALIGN=Top>#Fax#</td></TR>
<TR><td VALIGN=Top>E-Mail:</td><td VALIGN=Top>#Email#</td></TR>
<TR><td VALIGN=Top>Website:</td><td VALIGN=Top>#Website#</td></TR>
<TR><td VALIGN=Top>Facilities:</td><td VALIGN=Top>#Facilities#</td></TR>
</TABLE><HR>

</CFOUTPUT>
<br><A HREF=&quot;NavigationPage.htm&quot;>Return to Navigation Page</A>


</BODY>
 
I forgot. This is the error that is returned:

Variable PASSWORD is undefined.
-----------------------------------------------------
The Error Occurred in C:\CFusionMX\ line 4

2 :
3 : <CFIF Password NEQ Password2 OR
4 : LEN(TRIM(Form.Password)LTE 0)>
5 : <CFSET Error1=&quot;Please Check Password.<br>&quot;>
6 : </CFIF>
-----------------------------------------------------
the validation part is a recent addition. When I remove it it seem sto work fine, but when it's there... all the variable suddenly become &quot;Undefined&quot;. I just can't understand it.
 
Ah. I solved it. It was a problem with the META Refresh tag. I looked up some CF tags and found one called <CFLOCATION> which works like a treat.
 
OK, Looks to me like a simple orginizational goof:

<CFIF Password NEQ Password2 OR LEN(trim(password)) LTE 0>
<CFSET Error1=&quot;Please Check Password.<br>&quot;>
</cfif>

The LTE 0 moved outside the LEN call rather than inside it works as well. DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Cheers mate. That was another problem I was trying to address.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top