Connecting Tech Pros Worldwide Forums | Help | Site Map

ASP Login Page - Not matching up with Access table

Member
 
Join Date: Oct 2008
Location: Cleveland Ohio
Posts: 67
#1: Nov 3 '08
Hello,

I have created a login.asp page which i have posted below. When I login into my site, it automatically takes me to the redirect page "index.html" which means that i entered the wrong login information.

I believe i am not connecting to the access table correctly.

Here are some of the characters I used(hope this helps clear up my asp page)

Email --- this is the title to the login column in my access table
Password --- password column title in my table
email --- this is the "name" for the email input text box
password --- this is the "name" for the password input text box
dsn --- access_registration_db.dsn
Access database --- registration.mdb
tablename --- tblRegister

Any thoughts on where I went wrong? Thanks

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Function Login(Email, Password)
  3.  
  4. Dim cn
  5. Dim rs
  6. Dim strSQL
  7. Dim strCn
  8.  
  9. Set cn = CreateObject("ADODB.Connection")
  10. Set rs = CreateObject("ADODB.Recordset")
  11. strSQL = "SELECT * FROM tblRegister WHERE EmailName = '"
  12. strSQL = strSQL & Email & "'"
  13.  
  14. On Error Resume Next
  15. cn.ConnectionString = "DSN=access_registration_db.dsn" & Application("registration.mdb")
  16.  
  17. cn.Open
  18. If Err Then Exit Function
  19.  
  20. rs.Open strSQL, cn
  21. If Err Then Exit Function
  22. If rs("password") = Password Then
  23. Login = True
  24. Else
  25. Login = False
  26. End If
  27. rs.Close
  28. cn.Close
  29. Exit Function
  30. End Function
  31.  
  32. If Login(Request.Form("email"), Request.Form("password")) Then
  33. Response.REdirect "accountpage.html"
  34. Else
  35. Response.Redirect "index.html"
  36. End If
  37. %>

Member
 
Join Date: Oct 2008
Location: Cleveland Ohio
Posts: 67
#2: Nov 4 '08

re: ASP Login Page - Not matching up with Access table


sorry for this question, i figured it out. If there is a way to delete my post when i ask a question i figure out before someone else posts, please let me know.
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 930
#3: Nov 4 '08

re: ASP Login Page - Not matching up with Access table


Hi Jerry,

Moderators can delete posts but if you've answered your own question it's usually more helpful to reply to your post and let everyone know how you fixed it so that anybody else with the same problem can see how you did it.

Glad you got it sorted,

Dr B
Member
 
Join Date: Oct 2008
Location: Cleveland Ohio
Posts: 67
#4: Nov 4 '08

re: ASP Login Page - Not matching up with Access table


Ok, thanks for your reply.

I was way off on my code i posted above. At least I think i was.

I found a better code to use in a book called Active Server Pages 3.0 By Example.
Reply