Doesn't check if username or email exits in database properly

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2004
Posts: 4
Reputation: sunny124 is an unknown quantity at this point 
Solved Threads: 0
sunny124 sunny124 is offline Offline
Newbie Poster

Asp code doesn't check if username or email exits in database properly

 
0
  #1
Oct 29th, 2004
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.

  1. ' code for username loop
  2.  
  3. Do while not objRegisterRecordSet.EOF
  4.  
  5. if objRegisterRecordSet("tUserName") = Request.Form("user") then
  6.  
  7. Session("invaliduserName") = true ' username entered is in database
  8. exit do ' exits this loop
  9. else
  10. UserNamecounter = UserNamecounter + 1 ' username entered was not in that record
  11. end if
  12. objRegisterRecordSet.MoveNext ' goes to next record
  13. Loop
  14.  

  1. 'code for email loop
  2.  
  3. Do while not objRegisterRecordSet.EOF
  4. if objRegisterRecordSet("tEmail") = Request.Form("email") then
  5.  
  6. Session("invalidEmail") = true ' email entered is in database
  7. exit do ' exits loop
  8. else
  9. Emailcounter = Emailcounter +1 ' email entered was not found at this record
  10. end if
  11. objRegisterRecordSet.MoveNext ' goes to next record
  12. Loop
  13.  

  1. if Session("invalidEmail") = true OR Session("invaliduserName") = true then
  2. ' if username or email entered was found in database go to register.asp page
  3. Response.Redirect("Register.asp")
  4. end if
  5.  

  1. 'code for register.asp
  2. <%
  3. if Session("invaliduserName") = true then
  4. %>
  5. <p class="InvalidUsernameAndEmailRegisterd"> <% Response.write("The user name entered is already taken... Please choose another user name") %>
  6. </p>
  7.  
  8. <%
  9. Session("invaliduserName") = false
  10. End if %>
  11.  
  12. <%
  13. if Session("invaliduserName") = false then
  14. %>
  15. <p class="InvalidUsernameAndEmailRegisterd"> <% Response.write("") %></p>
  16. <%
  17.  
  18. End if %>
  19.  
  20.  
  21. <%
  22. if Session("invalidEmail") = true then
  23. %>
  24. <p class="InvalidUsernameAndEmailRegisterd">
  25. <% 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.")
  26. %>
  27. </p>
  28. <%
  29. Session("invalidEmail") = false
  30. end if %>
  31.  
  32. <%
  33. if Session("invalidEmail") = false then
  34. %>
  35. <p class="tabledata"> <% Response.write("") %></p>
  36. <%
  37.  
  38. End if %>
  39.  
Last edited by sunny124; Oct 29th, 2004 at 5:30 am. Reason: Wanted to change title
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC