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

All i want is to compare two form fields!!!!! 1

Status
Not open for further replies.

scuttleButt

Programmer
May 17, 2000
44
0
0
US
I GIVE UP!

I am trying to compare two passwords to make sure they match, seems simple enough. My code:

<%
goToHere = Request.ServerVariables(&quot;URL&quot;)
theString=Request.queryString(&quot;firstTime&quot;)

If theString <> &quot;true&quot; Then
DIM firstPassword
DIM secondPassword
firstPassword=Request.Form(&quot;password&quot;)
secondPassword=Request.Form(&quot;password2&quot;)
If firstPassword = secondPassword Then
Response.Redirect (&quot;splash.asp&quot;)
Else
Response.Redirect(&quot;pw_change.asp?valid=false&quot;)
End If
End IF
goToHere = Request.ServerVariables(&quot;URL&quot;)& &quot;?firstTime=false&quot;
%>

No matter what I type in the two passwords it always goes to splash.asp. So.. I comment out splash and response.write the two passwords to see what's in them and guess what? It works, when I type in non-matching passwords it comes back to itself (pw_change.asp) with a false and shows the word the passwords don't match. When I type in matching passwords it shows the pass words. See below.

<%
goToHere = Request.ServerVariables(&quot;URL&quot;)
theString=Request.queryString(&quot;firstTime&quot;)

If theString <> &quot;true&quot; Then
DIM firstPassword
DIM secondPassword
firstPassword=Request.Form(&quot;password&quot;)
secondPassword=Request.Form(&quot;password2&quot;)
If firstPassword = secondPassword Then
Response.Write (firstPassword)
Response.Write (secondPassword)
'Response.Redirect (&quot;splash.asp&quot;)
Else
Response.Redirect(&quot;pw_change.asp?valid=false&quot;)
End If
End IF
goToHere = Request.ServerVariables(&quot;URL&quot;)& &quot;?firstTime=false&quot;
%>

If I take out the response.writes and uncomment the response.redirect it's broke again.

WHAT AM I MISSING HERE?

Thanks ahead of time for any help... I'm desperate.

Donna
 
firstPassword = rtrim(Request.Form(&quot;password&quot;))
secondPassword = rtrim(Request.Form(&quot;password2&quot;))

and when you store everything uppercase, use the ucase() function.


br
Gerard
 
I added the rtrims but it is still not behaving. Same thing, weather I type in matching or non-matching passwords, it still goes into the first part of the if and goes to my splash.asp. Thanks for the suggestion though... I should always include trims when trying to match up two variables like that.

Donna
 
test132434.asp:

<%@ Language=VBScript %>
<%
if request.servervariables(&quot;REQUEST_METHOD&quot;) = &quot;POST&quot; then
dim fPwd, sPwd
fPwd = rtrim(Request.Form(&quot;password&quot;))
sPwd = rtrim(Request.Form(&quot;password2&quot;))
If fPwd = sPwd then
Response.Redirect &quot;splash.asp&quot;
Response.End
else
Response.Write &quot;PASSWORDS NOT EQUAL!<br>&quot;
end if
end if
%>
<form method=post action=test132434.asp>
<input type=hidden name=firsttime value=Y>
Password 1: <input type=text name=password><br>
Again: <input type=text name=password2><br>
<input type=submit>
</form>

br
Gerard
 
Thank you Gerard, the &quot;request.servervariables(&quot;REQUEST_METHOD&quot;) = &quot;POST&quot; was what did the trick. I learned something new today. I appreciate the help and I voted.

Siiiighhhhh,
Donna X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top