Forums
This topic is locked
need help with new user registration
16 May 2006 20:51:03 jason Sum posted:
I just doing a login page with dreamweaver 8, having problem trying to check if a user name and email are already register in the database, to check the user name is really easy but i am trying to check the email as well i just wonder if any one know how to mode the code..cheers, and i am using <b>(asp vb script)</b>
Replies
Replied 16 May 2006 20:52:03
16 May 2006 20:52:03 jason Sum replied:
I think that the code created by dreamweaver where would i change to check the email as well?
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "" Then
MM_dupKeyRedirect="register.asp?ErrMsg=对不起,您输入的用户名 已经被他人使用,请选择其他名字后再试。"
MM_rsKeyConnection=MM_conn_STRING
MM_dupKeyUsernameValue = CStr(Request.Form("UsrNickName")
MM_dupKeySQL="SELECT UsrNickName FROM Users WHERE UsrNickName='" & Replace(MM_dupKeyUsernameValue,"'","''" & "'"
MM_adodbRecordset="ADODB.Recordset"
set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
MM_rsKey.ActiveConnection=MM_rsKeyConnection
MM_rsKey.Source=MM_dupKeySQL
MM_rsKey.CursorType=0
MM_rsKey.CursorLocation=2
MM_rsKey.LockType=3
MM_rsKey.Open
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
' the username was found - can not add the requested username
MM_qsChar = "?"
If (InStr(1,MM_dupKeyRedirect,"?" >= 1) Then MM_qsChar = "&"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
Response.Redirect(MM_dupKeyRedirect)
End If
MM_rsKey.Close
End If
%>
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "" Then
MM_dupKeyRedirect="register.asp?ErrMsg=对不起,您输入的用户名 已经被他人使用,请选择其他名字后再试。"
MM_rsKeyConnection=MM_conn_STRING
MM_dupKeyUsernameValue = CStr(Request.Form("UsrNickName")
MM_dupKeySQL="SELECT UsrNickName FROM Users WHERE UsrNickName='" & Replace(MM_dupKeyUsernameValue,"'","''" & "'"
MM_adodbRecordset="ADODB.Recordset"
set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
MM_rsKey.ActiveConnection=MM_rsKeyConnection
MM_rsKey.Source=MM_dupKeySQL
MM_rsKey.CursorType=0
MM_rsKey.CursorLocation=2
MM_rsKey.LockType=3
MM_rsKey.Open
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
' the username was found - can not add the requested username
MM_qsChar = "?"
If (InStr(1,MM_dupKeyRedirect,"?" >= 1) Then MM_qsChar = "&"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
Response.Redirect(MM_dupKeyRedirect)
End If
MM_rsKey.Close
End If
%>
Replied 17 May 2006 00:07:32
17 May 2006 00:07:32 micah santos replied:
I'm not gonna use the generated scripts by DMX, however, I can show you how will you insert another recordset query.
<%
// Variables
Dim rsUsername
Dim rsEmail
%>
<%
// Query username in the database
// If found, display message
Set rsUsername = ObjConn.Execute("SELECT * FROM tblUsers WHERE userName='" & Request.Form("glUsername" & "'"
If NOT rsUsername.EOF Then
// Username is found
response.write "This username is already in used!"
Else
// Username is not found
// Now, check for the e-mail address
Set rsEmail = ObjConn.Execute("SELECT * FROM tblUsers WHERE userEmail='" & Request.Form("glEmail" & "'"
If NOT rsEmail.EOF Then
response.write "You can only register once!"
Else
// proceed to saving all records
End If
rsEmail.Close
Set rsEmail = Nothing
End If
rsUsername.Close
Set rsUsername = Nothing
%>
<%
// Variables
Dim rsUsername
Dim rsEmail
%>
<%
// Query username in the database
// If found, display message
Set rsUsername = ObjConn.Execute("SELECT * FROM tblUsers WHERE userName='" & Request.Form("glUsername" & "'"
If NOT rsUsername.EOF Then
// Username is found
response.write "This username is already in used!"
Else
// Username is not found
// Now, check for the e-mail address
Set rsEmail = ObjConn.Execute("SELECT * FROM tblUsers WHERE userEmail='" & Request.Form("glEmail" & "'"
If NOT rsEmail.EOF Then
response.write "You can only register once!"
Else
// proceed to saving all records
End If
rsEmail.Close
Set rsEmail = Nothing
End If
rsUsername.Close
Set rsUsername = Nothing
%>
Replied 17 May 2006 00:12:25
17 May 2006 00:12:25 micah santos replied:
using the generated scripts, this is where you put another recordset to search for the email address
<%
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
' the username was found - can not add the requested username
MM_qsChar = "?"
If (InStr(1,MM_dupKeyRedirect,"?" >= 1) Then MM_qsChar = "&"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
Response.Redirect(MM_dupKeyRedirect)
End If
// starting from this part
ELSE
// Below this line
// Create another recordset for e-maill address just like the first one for the username
End If
MM_rsKey.Close
%>
<%
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
' the username was found - can not add the requested username
MM_qsChar = "?"
If (InStr(1,MM_dupKeyRedirect,"?" >= 1) Then MM_qsChar = "&"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
Response.Redirect(MM_dupKeyRedirect)
End If
// starting from this part
ELSE
// Below this line
// Create another recordset for e-maill address just like the first one for the username
End If
MM_rsKey.Close
%>
Replied 17 May 2006 04:34:36
17 May 2006 04:34:36 jason Sum replied:
Hi micah
where would the code above go into the generated scripts.
where would the code above go into the generated scripts.
Replied 17 May 2006 06:53:49
17 May 2006 06:53:49 micah santos replied:
basically, you only need to create another recordset in your IF ElSE statement. the code i posted here is just another way to achieve that specific task you're dealing with.
<%
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
// the username was found - can not add the requested username
ELSE
// Then, create another recordset for e-maill address just like the first one for the username
End If
%>
<%
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
// the username was found - can not add the requested username
ELSE
// Then, create another recordset for e-maill address just like the first one for the username
End If
%>