944,167 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 2819
  • ASP RSS
Oct 24th, 2005
0

login

Expand Post »
i ahve database in which i hava login information iwa nted to check weather the persons login information is correct or wrong.
i m very new to asp. so any body help how i have to proceed

<%dim user,pass
user=request.form("usercode")
pass=request.form("pass")
response.write(user)
response.write(pass)
' Open database
Dim Conn, RS
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Driver={MySql ODBC 3.51 Driver}; Server=localhost; database=slogin; uid=user

; pwd=pass option=3;"
Set RS = Conn.Execute("SELECT * From userss where username='user' and password='pass'")
if RS="user" then
response.write("login")
end if
%>
i m trying some how like this but getting error. i think i dont know how to check the login information with database .pls help
Similar Threads
Reputation Points: 11
Solved Threads: 0
Junior Poster
aarya is offline Offline
139 posts
since Sep 2005
Nov 6th, 2005
0

Re: login

here is the code that can help you in designing the login page for the users. It is well commented so I think you will have no problem in understanding that.
ASP Syntax (Toggle Plain Text)
  1. <%
  2. Dim adoConn 'Database Connection Variable
  3. Dim rsCheckUser 'Database Recordset Variable
  4. Dim strSQL 'Database query sring
  5. Dim strUserName 'Holds the user name
  6. Dim strPassword 'Holds the Password
  7.  
  8. 'Initalise the strUserName variable
  9. strUserName = Request.Form("UserName")
  10. strPassword = Request.Form("Passowrd")
  11.  
  12. 'Create a connection odject
  13. Set adoConn = Server.CreateObject("ADODB.Connection")
  14. adoConn.Open "Driver={MySql ODBC 3.51 Driver}; Server=localhost; database=slogin; uid=user
  15. 'Create a recordset object
  16. Set rsCheckUser = Server.CreateObject("ADODB.Recordset")
  17.  
  18. 'Initalise the strSQL variable with an SQL statement to query the database
  19. strSQL = "SELECT UserName, Password FROM tblUsers WHERE UserName ='" & strUserName & "'"
  20.  
  21. 'Query the database
  22. rsCheckUser.Open strSQL, adoConn
  23.  
  24. 'If the recordset finds a record for the username entered then read in the password for the user
  25. If NOT rsCheckUser.EOF Then
  26.  
  27. 'Read in the password for the user from the database
  28. If (strPassword) = rsCheckUser("Password") Then
  29.  
  30. 'If the password is correct then set the session variable to True
  31. Session("LoggedIn") = True
  32.  
  33. 'Close Objects before redirecting
  34. Set adoCon = Nothing
  35. Set strCon = Nothing
  36. Set rsCheckUser = Nothing
  37.  
  38. 'Redirect to the authorised user page and send the users name
  39. Response.Redirect "loggedin.asp"
  40. End If
  41. End If
  42.  
  43. 'Close Objects
  44. Set adoCon = Nothing
  45. Set strCon = Nothing
  46. Set rsCheckUser = Nothing
  47.  
  48. 'If the script is still running then the user must not be authorised
  49. Session("LoggedIn") = False
  50. 'Redirect to the unautorised user page
  51. Response.Redirect "login.asp"
  52. %>
Reputation Points: 9
Solved Threads: 1
Junior Poster in Training
msaqib is offline Offline
91 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: How to specify a port number
Next Thread in ASP Forum Timeline: SQL Query inserts junk data as well





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC