Create Login Page with ASP Connected to Database

dim username, password, loginButton
if logButton then
   Dim Con, sql, rec
   set Con = Server.CreateObject("ADODB.Connection")
   Con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("database.mdb")
   'Select the record matching the username.
   sql = "SELECT * FROM tblusers WHERE UCase(username)='
"& UCase(username) & "' AND UCase(password)=' " & UCase(password) & " ' "
   set rec=Con.execute(sql)
   'If no match found, EOF is not true.
   if NOT rec.EOF then
      Response.Redirect("somepage.asp") 'Change to page redirect to after login
      blankError="Invalid username." 'EOF is true, no match found.
   end if
end if
<form name="productForm" method="post" action="<%=Request.ServerVariables("URL")%>">
<table border =1>
<tr><td colspan="2">

if blankError<>"" then
Response.Write("<center><font color='red' size='3'>"&blankError&"</font></center>")
end if
<td><Strong><font face="courier new" size="3">Username:</font></strong></td>
<td><input type="text" name="username" size="35"></td>
<td><Strong><font face="courier new" size="3">Password</font></strong></td>
<td><input type="password" name="password" size="35"></td>
<tr><td colspan="2" align="center"><input type="submit" name="loginButton" value="Login">
<input type="reset" name="reset" value="Clear"></td>

No comments:

Post a Comment

Please Provide your feedback here