I have set up this password login script no problems which validates Password / username are in the Access DB I have created three fields in the DB password, username and passwordindex (an autoindex number). How can i customise this script to retrieve the DB created autoindex number and turn it into a variable and then display on the Response. Redirect page ie. protectedpage2.asp . Please can any one help?
Thanks
login.asp page as is:
<%
Response.Expires = -1000 'Makes the browser not cache this page
Response.Buffer = True 'Buffers the content so our Response.Redirect will work
Dim Error_Msg
login = Request.Form("login"
If login = "login_again" Then
Session("UserLoggedIn"
= ""
ShowLogin
Else
If Session("UserLoggedIn"
= "true" Then
AlreadyLoggedIn
Else
If login = "true" Then
CheckLogin
Else
ShowLogin
End If
End If
End If
Sub ShowLogin
Response.Write(Error_Msg & "<br>"
%>
<form name=form1 action=login2.asp method=post>
User Name : <input type=text name=username><br>
Password : <input type=password name=userpwd><br>
<input type=hidden name=login value=true>
<input type=submit value="Login">
</form>
<%
End Sub
Sub AlreadyLoggedIn
%>
You are already logged in.
Do you want to logout or login as a different user?
<form name=form2 action=login2.asp method=post>
<input type=submit name=button1 value='Yes'>
<input type=hidden name=login value='login_again'>
</form>
<%
End Sub
Sub CheckLogin
Dim Conn, cStr, sql, RS, username, userpwd, indexno
username = Request.Form("username"
userpwd = Request.Form("userpwd"
Set Conn = Server.CreateObject("ADODB.Connection"
cStr = "DRIVER={Microsoft Access Driver (*.mdb)};"
cStr = cStr & ("DBQ=C:\password.mdb"
& ";"
Conn.Open(cStr)
sql = "select passwordindex from UserTable where username = '" & LCase(username) & "'"
sql = sql & " and userpwd = '" & LCase(userpwd) & "'"
Set RS = Conn.Execute(sql)
If RS.BOF And RS.EOF Then
Error_Msg = "Login Failed. Try Again."
ShowLogin
Else
Session("UserLoggedIn"
= "true"
Response.Redirect "protectedpage2.asp"
End If
End Sub
%>
Thanks
login.asp page as is:
<%
Response.Expires = -1000 'Makes the browser not cache this page
Response.Buffer = True 'Buffers the content so our Response.Redirect will work
Dim Error_Msg
login = Request.Form("login"
If login = "login_again" Then
Session("UserLoggedIn"
ShowLogin
Else
If Session("UserLoggedIn"
AlreadyLoggedIn
Else
If login = "true" Then
CheckLogin
Else
ShowLogin
End If
End If
End If
Sub ShowLogin
Response.Write(Error_Msg & "<br>"
%>
<form name=form1 action=login2.asp method=post>
User Name : <input type=text name=username><br>
Password : <input type=password name=userpwd><br>
<input type=hidden name=login value=true>
<input type=submit value="Login">
</form>
<%
End Sub
Sub AlreadyLoggedIn
%>
You are already logged in.
Do you want to logout or login as a different user?
<form name=form2 action=login2.asp method=post>
<input type=submit name=button1 value='Yes'>
<input type=hidden name=login value='login_again'>
</form>
<%
End Sub
Sub CheckLogin
Dim Conn, cStr, sql, RS, username, userpwd, indexno
username = Request.Form("username"
userpwd = Request.Form("userpwd"
Set Conn = Server.CreateObject("ADODB.Connection"
cStr = "DRIVER={Microsoft Access Driver (*.mdb)};"
cStr = cStr & ("DBQ=C:\password.mdb"
Conn.Open(cStr)
sql = "select passwordindex from UserTable where username = '" & LCase(username) & "'"
sql = sql & " and userpwd = '" & LCase(userpwd) & "'"
Set RS = Conn.Execute(sql)
If RS.BOF And RS.EOF Then
Error_Msg = "Login Failed. Try Again."
ShowLogin
Else
Session("UserLoggedIn"
Response.Redirect "protectedpage2.asp"
End If
End Sub
%>