Home | Advertising Info6 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Thursday, March 28, 2024  

  Active InfoActive Info  Display List of Info MembersMemberlist  Search The InfoSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - Database Issues
 PowerASP Code Help Area : Classic ASP - Database Issues
Subject Info: Problem With variables and forms A d d  -  P o s tAdd P o s t
Author
Message << Prev Info | Next Info >>
marcrock
Newbie
Newbie


Joined: November/05/2005
Location: Brazil
Online Status: Offline
Info: 1
Added: November/05/2005 at 7:15am | IP Logged Quote marcrock

Hello.

I have a response page that collect the user name and the password from html forms. Then, to handle the information I use 2 variables:

Dim theUser, oldPass

theUser = LCase(Request.Form("txtUserName"))
oldPass = Request.Form("txtUserPass")

I named the password as "oldPass" because I'd like to allow the user to change it, and this is the purpose of this page. Then, I named two other variables to collect the new password and to redigit it again:

Dim newPass1, newPass2

newPass1 = Request.Form("newPass1")
newPass2 = Request.Form("newPass2")

After, I created the connection to my SQL DB:

sqlText = "SELECT * FROM USERS WHERE user = '" & theUser & "' " & "AND password = '" & oldPass & "';"
set oConn=Server.CreateObject("ADODB.connection")
oConn.open "DRIVER={SQL Server}; SERVER=msde20i.terraempresas.com; DSN=neumans; UID=neumans; PWD=q5r8f388"
Set oRSdb = Server.CreateObject("ADODB.Recordset")
oRSdb.Open sqlText, oConn
oRSdb.MoveFirst()

Then I created another varible to hold the database user name:

Dim theUserDB
theUserDB = LCase(oRSdb("user"))

Until now, everything goes fine. My problem is when I try to compare the database user name and the user name collected from the form:

If theUser = theUserDB Then
 Response.Write "OK."
Else
 Response.Write "Why they're not recognized as the same???"
End If

Why I can't get the "OK" result? Why the code says always that, for example, john isn't john?
Can anyone help me to solve this? What's the trick? What I have missed?

Thank you very much.



__________________
Marcelo Rocha
Designer and Illustrator
Back to Top View marcrock's Profile Search for other info by marcrock
 
cwilliams
Admin Group
Admin Group
Avatar

Joined: April/26/2004
Location: United States
Online Status: Offline
Info: 137
Added: November/07/2005 at 11:24pm | IP Logged Quote cwilliams

1st, I hope that SQL connection info you posted here isn't real isn't real. :)

2nd. you need to do some old fashioned debugging.

For example response write both those values within ()'s or something.. response write a  <br> after each

then see if they visually match up and both produce values and go from there..

often times reponse writing info .. sometimes even response ending right after.... in various spots will allow to follow the logic step by and ensure what you think should be happening is

its really the only good way we can debug in classic ASP

You are sort of already doing that but dsiplaying both values on the screen will tell you more than just askin if they are the same.

of course, obviously they are not at that point...

__________________


Chris Williams
http://www.PowerASP.com
Back to Top View cwilliams's Profile Search for other info by cwilliams
 
firas_TheGeek
Newbie
Newbie
Avatar

Joined: May/27/2006
Location: Oman
Online Status: Offline
Info: 28
Added: May/27/2006 at 9:33am | IP Logged Quote firas_TheGeek

The problem is very simple, and it happened with me before and still happing till now

the problem that john in not john because of the field and variable type

to solve it use this code

If cstr(lcase(theUser)) = cstr(lcase(theUserDB)) Then
 
Response.Write "OK."
Else
 Response.Write "Why they're not recognized as the same???"
End If

 

what i did is ensuerd that both of them are lowered case and both of them are strings

 

Hope this helps

tell me what happens with you?

 

Best Regards



__________________
Firas S Assaad (TheGeek)
firas489@gmail.com
0096892166434
http://firas-thegeek.blogspot.com
Back to Top View firas_TheGeek's Profile Search for other info by firas_TheGeek Visit firas_TheGeek's Homepage
 

If you wish to make a comment to this info you must first login
If you are not already registered you must first register

  A d d  -  P o s tAdd P o s t
Printable version Printable version

Info Jump
You cannot add new info in this area
You cannot add to info in this area
You cannot delete your info in this area
You cannot edit your info in this area
You cannot create polls in this area
You cannot vote in polls in this area

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2024 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

Active Server Pages ASP a directory of ASP tutorials applications scripts components and articles for the novice to professional developer. CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com