newkid
08-24-2004, 04:36 PM
I have some code I borrowed and it works fine. it's an easy login/password program (w / access back end).
1. I want to change it, when a user enters a valid User-Id & password that it automaticaly sends them to specific page (IE. valid_page.asp)
2. Is there any way to check in the page (valid_page.asp) that the previous page was login.asp (that it was called from login.asp). To prevent some one from just entering http://myserver/valid_page.asp so that they would have to go thru login.asp. and if they did try and go straight to valid_page.asp it would send them to login.asp?
PS I've been searching google and here but can't find a solution (not really sure what to search on)
Thanks for all help in advance
J.C.
To learn is a good thing and today I hope to learn something new.
<%@ Language = "VBScript" %>
<%
Option Explicit
Dim cnnLogin
Dim rstLogin
Dim strUsername, strPassword
Dim strSQL
%>
<html>
<head><title>Login Page</title>
</head>
<body bgcolor="gray">
<%
If Request.Form("action") <> "validate_login" Then
%>
<form action="login.asp" method="post">
<input type="hidden" name="action" value="validate_login" />
<table border="0">
<tr>
<td align="right">Enter User-ID:</td>
<td><input type="text" name="login" /></td>
</tr>
<tr>
<td align="right">Enter Password:</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td align="right"></TD>
<td><input type="submit" VALUE="Login" /></td>
</tr>
</table>
</form>
<%
Else
strSQL = "SELECT * FROM tblLoginInfo " _
& "WHERE username='" & Replace(Request.Form("login"), "'", "''") & "' " _
& "AND password='" & Replace(Request.Form("password"), "'", "''") & "';"
Set cnnLogin = Server.CreateObject("ADODB.Connection")
cnnLogin.Open("DRIVER={Microsoft Access Driver (*.mdb)};" _
& "DBQ=" & Server.MapPath("login.mdb"))
Set rstLogin = cnnLogin.Execute(strSQL)
If Not rstLogin.EOF Then
%>
<p><strong>Valid User-ID / Password</strong></p>
<a href="valid_page.asp">Click here to Continue</a>
</p>
<%
Else
%>
<p><font size="4" face="arial,helvetica"><strong>
Login Failed - Please verify username and password.
</strong></font></p>
<p>
<a href="login.asp">Try Again</a>
</p>
<%
'Response.End
End If
' Clean Up
rstLogin.Close
Set rstLogin = Nothing
cnnLogin.Close
Set cnnLogin = Nothing
End If
%>
</body>
</html>
1. I want to change it, when a user enters a valid User-Id & password that it automaticaly sends them to specific page (IE. valid_page.asp)
2. Is there any way to check in the page (valid_page.asp) that the previous page was login.asp (that it was called from login.asp). To prevent some one from just entering http://myserver/valid_page.asp so that they would have to go thru login.asp. and if they did try and go straight to valid_page.asp it would send them to login.asp?
PS I've been searching google and here but can't find a solution (not really sure what to search on)
Thanks for all help in advance
J.C.
To learn is a good thing and today I hope to learn something new.
<%@ Language = "VBScript" %>
<%
Option Explicit
Dim cnnLogin
Dim rstLogin
Dim strUsername, strPassword
Dim strSQL
%>
<html>
<head><title>Login Page</title>
</head>
<body bgcolor="gray">
<%
If Request.Form("action") <> "validate_login" Then
%>
<form action="login.asp" method="post">
<input type="hidden" name="action" value="validate_login" />
<table border="0">
<tr>
<td align="right">Enter User-ID:</td>
<td><input type="text" name="login" /></td>
</tr>
<tr>
<td align="right">Enter Password:</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td align="right"></TD>
<td><input type="submit" VALUE="Login" /></td>
</tr>
</table>
</form>
<%
Else
strSQL = "SELECT * FROM tblLoginInfo " _
& "WHERE username='" & Replace(Request.Form("login"), "'", "''") & "' " _
& "AND password='" & Replace(Request.Form("password"), "'", "''") & "';"
Set cnnLogin = Server.CreateObject("ADODB.Connection")
cnnLogin.Open("DRIVER={Microsoft Access Driver (*.mdb)};" _
& "DBQ=" & Server.MapPath("login.mdb"))
Set rstLogin = cnnLogin.Execute(strSQL)
If Not rstLogin.EOF Then
%>
<p><strong>Valid User-ID / Password</strong></p>
<a href="valid_page.asp">Click here to Continue</a>
</p>
<%
Else
%>
<p><font size="4" face="arial,helvetica"><strong>
Login Failed - Please verify username and password.
</strong></font></p>
<p>
<a href="login.asp">Try Again</a>
</p>
<%
'Response.End
End If
' Clean Up
rstLogin.Close
Set rstLogin = Nothing
cnnLogin.Close
Set cnnLogin = Nothing
End If
%>
</body>
</html>