PDA

Click to See Complete Forum and Search --> : Checking UserID


jesus4u
Feb 16th, 2001, 10:34 AM
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?

Feb 16th, 2001, 08:52 PM
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,
:o Mac :)