Comparing strings to database query results

Results 1 to 4 of 4

Thread: Comparing strings to database query results

  1. #1
    Tinman Guest

    Default Comparing strings to database query results

    I&#039;m trying to make a very simple user authentication program. The user enters his Username and PW into a form, then the results are sent to an .asp page. The code looks something like this: (mostly pseudocode here)<BR>var username = Request.Form("text");<BR>users = open usernames from usertable<BR>loop until users.eof<BR>if (username == users(0)) {<BR>Redirect user to appropriate page<BR>}<BR>users.MoveNext();<BR>loop<BR>But for some reason, the if condition is never satisfied, even though I know the two are the same. Is this because users(0) refers to an object and the variable username to a string? Any help would be appreciated Thanks -Tinman<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default do the compare with sql

    "select userNames from userTable where userNames=&#039; & userName & "&#039; And password=&#039;" & password & "&#039;"<BR><BR>than if rs.eof invalid username pasword combo<BR>

  3. #3
    Tinman Guest

    Default Nevermind figured it out (solution inside for any1

    Instead of comparing username to users(0), I created a variable like this to perform the comparison.<BR><BR>var cusername = "" + users(0) + "";<BR><BR>And it worked fine, so I guess the problem was that I was trying to compare two different types of data, and it couldn&#039;t return true.

  4. #4
    Tinman Guest

    Default Yeah I coulda done it that way too, thanks


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts