login

Reply

Join Date: Sep 2005
Posts: 139
Reputation: aarya is an unknown quantity at this point 
Solved Threads: 0
aarya's Avatar
aarya aarya is offline Offline
Junior Poster

login

 
0
  #1
Oct 24th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 89
Reputation: msaqib is an unknown quantity at this point 
Solved Threads: 1
msaqib msaqib is offline Offline
Junior Poster in Training

Re: login

 
0
  #2
Nov 6th, 2005
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.
  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. %>
Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the ASP Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC