Home | Advertising Info8 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Monday, May 13, 2024  

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - Database Issues
 PowerASP Code Help Area : Classic ASP - Database Issues
Subject Topic: Problem With variables and forms Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
marcrock
Newbie
Newbie


Joined: November/05/2005
Location: Brazil
Online Status: Offline
Posts: 1
Posted: 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 posts by marcrock
 
cwilliams
Admin Group
Admin Group
Avatar

Joined: April/26/2004
Location: United States
Online Status: Offline
Posts: 137
Posted: 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 posts by cwilliams
 
firas_TheGeek
Newbie
Newbie
Avatar

Joined: May/27/2006
Location: Oman
Online Status: Offline
Posts: 28
Posted: 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 posts by firas_TheGeek Visit firas_TheGeek's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

   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 ASP.NET .aspx .ascx Web HTML Developer Internet Microsoft Web Services Visual Studio .NET CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com