Results 1 to 2 of 2

Thread: Checking UserID

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    I am trying to add code to check for duplicate userID.

    Set cmdDC = Server.CreateObject("ADODB.Command")
    cmdDC.ActiveConnection = DataConnection

    '-- default SQL
    SQL = "SELECT * FROM UserRegistration"

    If Request.Form("name") <> "" Then
    SQL = "SELECT * FROM Register WHERE " & _
    "Register.userID='" & strUserID & "' AND " & _
    "Register.password ='" & strPassword & _
    "' OR Register.email ='" & strEmail & "'"
    End If

    cmdDC.CommandText = SQL
    Set RecordSet = Server.CreateObject("ADODB.Recordset")



    '-- Cursor Type, Lock Type

    '-- ForwardOnly 0 - ReadOnly 1

    '-- KeySet 1 - Pessimistic 2

    '-- Dynamic 2 - Optimistic 3

    '-- Static 3 - BatchOptimistic 4



    RecordSet.Open cmdDC, , 0, 2




    If Not RecordSet.EOF Then

    If RecordSet.fields("userID")=strUserID Then

    Response.Redirect "usernamerror.asp"

    Else

    Response.Redirect "userpassworderror.asp"

    End If



    It does not work properly! It doesn't even check the userID. But if I change the If RecordSet.fields("userID")=strUserID Then to say If RecordSet.fields("email")=stremail then it works properly.

    What shall I do?

    Is the problem within the RecordSet.Open cmdDC, , 0, 2?

  2. #2
    Guest

    Cool

    Hi....try this


    bExist = False

    Do While Not Recordset.EOF

    if RecordSet.fields("userID")=strUserID Then
    bExist = True
    End If

    Recordset.Movenext
    Loop

    if bExist = True then
    Response.Redirect "usernamerror.asp"
    Else
    Response.Redirect "userpassworderror.asp"
    End if



    Regards,
    Mac

Posting Permissions

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



Click Here to Expand Forum to Full Width