Forums

ASP

This topic is locked

need help with new user registration

Posted 16 May 2006 20:51:03
1
has voted
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)) &lt;&gt; "" Then
MM_dupKeyRedirect="register.asp?ErrMsg=&#23545;&#19981;&#36215;&#65292;&#24744;&#36755;&#20837;&#30340;&#29992;&#25143;&#21517; &#24050;&#32463;&#34987;&#20182;&#20154;&#20351;&#29992;&#65292;&#35831;&#36873;&#25321;&#20854;&#20182;&#21517;&#23383;&#21518;&#20877;&#35797;&#12290;"
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,"?" &gt;= 1) Then MM_qsChar = "&"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
Response.Redirect(MM_dupKeyRedirect)
End If
MM_rsKey.Close
End If
%&gt;
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.

&lt;%

// Variables
Dim rsUsername
Dim rsEmail

%&gt;

&lt;%

// 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


%&gt;
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

&lt;%

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,"?" &gt;= 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


%&gt;
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.
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.

&lt;%

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

%&gt;

Reply to this topic