469,950 Members | 2,480 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

please help me to correct my register code

hai
I need to write a code for register page of my website
i have written the following code,
<%
DIM strusername, strpassword, stremail
strUsername =request.form("username")
strPassword = request.form("password")
strEmail = request.form("email")


DIM my_SQL, objRS

my_sql= "SELECT username FROM User_list WHERE username='"&strusername&"'"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.CursorType = 1
objRS.lockType = 3
objRS.Open mySQL, objConn
if objrs.EOF Then


objRS.AddNew
objRS("Username")=strUsername
objRS("Password")=strPassword
objRS("Email")=strEmail
objRS("date")=date()
objRS.Update
objRS.Close
Set objRS = Nothing
Response.Write "You have been successfully registered as: " & strUsername

ELSE

DIM X, strTempUsername, intCount, mySQL2, objRS2
DO UNTIL X=True
intCount = intCount + 1
strTempUsername = strUsername & intCount
strUsername = strTempUsername

mySQL2 = "SELECT * FROM tblMembers WHERE fUsername = ' " & strUsername & " ' "
Set objRS2 = Server.CreateObject("ADODB.Recordset")
objRS2.Open mySQL2, objConn, adOpenKeyset, adLockPessimistic, adCmdText
IF objRS2.EOF THEN
X=True
ELSE
intCount = intCount
END IF
LOOP

objRS2.Close
Set objRS2 = Nothing

Response.Write "That username has already been registered. Please click Back on your browser and try a different username. "
Response.Write "We suggest you try the below available username:</p>"
Response.Write "<b> " & strUsername2 & "</b>"
END IF
%>
problem is without checking existing username ,data are storing in database

please guide me to correct this logic ....

Regards
sona
Jan 11 '07 #1
2 1129
shweta123
692 Expert 512MB
Hi,

Check strUsername by Trimming it. Trim(strUsername) .It may be missing by taking some blank places.Also check for UCase or LCase letters.It may be mismatching in that.

Shweta
Jan 16 '07 #2
Maybe you can try
if objrs.recordcount > 0 Then
to check for duplicate entry instead of objrs.EOF
Jan 18 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by David Goodyear | last post: by
1 post views Thread by Gaffar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.