Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access DB password script

Status
Not open for further replies.

gus121

Technical User
May 9, 2002
298
GB
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(&quot;login&quot;)
If login = &quot;login_again&quot; Then
Session(&quot;UserLoggedIn&quot;) = &quot;&quot;
ShowLogin
Else
If Session(&quot;UserLoggedIn&quot;) = &quot;true&quot; Then
AlreadyLoggedIn
Else
If login = &quot;true&quot; Then
CheckLogin
Else
ShowLogin
End If
End If
End If

Sub ShowLogin
Response.Write(Error_Msg & &quot;<br>&quot;)
%>
<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=&quot;Login&quot;>
</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(&quot;username&quot;)
userpwd = Request.Form(&quot;userpwd&quot;)
Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
cStr = &quot;DRIVER={Microsoft Access Driver (*.mdb)};&quot;
cStr = cStr & (&quot;DBQ=C:\password.mdb&quot;) & &quot;;&quot;
Conn.Open(cStr)
sql = &quot;select passwordindex from UserTable where username = '&quot; & LCase(username) & &quot;'&quot;
sql = sql & &quot; and userpwd = '&quot; & LCase(userpwd) & &quot;'&quot;
Set RS = Conn.Execute(sql)
If RS.BOF And RS.EOF Then
Error_Msg = &quot;Login Failed. Try Again.&quot;
ShowLogin
Else
Session(&quot;UserLoggedIn&quot;) = &quot;true&quot;

Response.Redirect &quot;protectedpage2.asp&quot;
End If
End Sub
%>
 
Basicly I want to convert the password index field passwordIndex I have retrieved from the DB using SQL into a variable. can any one help?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top