hi,
I have created a registration form. When the user clicks submit it goes to processRegister.asp. This is where it checks whether the username and email already exits in the database.
When i enter a email that is already in the database, the error message for the email and the username shows up.. Even if i entered a completely new username that is not in the database.
The email error message is working... but why does the username error message show up.
The email's do while loop excutes right after the do while loop for username has executed.
The block of code right towards the bottom excutes in register.asp page.
' code for username loop
Do while not objRegisterRecordSet.EOF
if objRegisterRecordSet("tUserName") = Request.Form("user") then
Session("invaliduserName") = true ' username entered is in database
exit do ' exits this loop
else
UserNamecounter = UserNamecounter + 1 ' username entered was not in that record
end if
objRegisterRecordSet.MoveNext ' goes to next record
Loop
'code for email loop
Do while not objRegisterRecordSet.EOF
if objRegisterRecordSet("tEmail") = Request.Form("email") then
Session("invalidEmail") = true ' email entered is in database
exit do ' exits loop
else
Emailcounter = Emailcounter +1 ' email entered was not found at this record
end if
objRegisterRecordSet.MoveNext ' goes to next record
Loop
if Session("invalidEmail") = true OR Session("invaliduserName") = true then
' if username or email entered was found in database go to register.asp page
Response.Redirect("Register.asp")
end if
'code for register.asp
<%
if Session("invaliduserName") = true then
%>
<p class="InvalidUsernameAndEmailRegisterd"> <% Response.write("The user name entered is already taken... Please choose another user name") %>
</p>
<%
Session("invaliduserName") = false
End if %>
<%
if Session("invaliduserName") = false then
%>
<p class="InvalidUsernameAndEmailRegisterd"> <% Response.write("") %></p>
<%
End if %>
<%
if Session("invalidEmail") = true then
%>
<p class="InvalidUsernameAndEmailRegisterd">
<% Response.Write("The email entered already exist in our database... Either you are already a memeber or you have given an incorrect email. Please enter an correct email please.")
%>
</p>
<%
Session("invalidEmail") = false
end if %>
<%
if Session("invalidEmail") = false then
%>
<p class="tabledata"> <% Response.write("") %></p>
<%
End if %>