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!

Passing variables between ASP pages 1

Status
Not open for further replies.

gus121

Technical User
May 9, 2002
298
GB
Hi this is a password login script I kind of borrowed and customised.
I simply wish to pass the variable indexno via the response.redirect url string protectedpage2.asp

Please can anyone help me?

thanks

Gus
<%
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
Set indexno = RS(&quot;passwordindex&quot;)
Session(&quot;UserLoggedIn&quot;) = &quot;true&quot;
Response.Redirect &quot;protectedpage2.asp&quot;
End If
End Sub
%>
 
If you don't want to use
Response.Redirect &quot;protectedpage2.asp?indexno=&quot; & indexno
because you don't want people to see the variable, then you could put indexno in a session variable.

 
Thanks for your help i new it would be something very simple.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top