Simple login script
Simple login script
By Roland Mensenkamp
15 June 2001
There's always a situation where you want to protect a page (or more).
Here's a simple script to solve a situation like that.
We use a 'Session variable' (so your cookies have to be on).
index.asp
<%
If Session("pass") Then
Response.Redirect "page1.asp"
Else
If Request.Form("pass") <> "" Then
If Request.Form("pass") = "yourpassword" Then
Session("pass") = True
Response.Redirect "page1.asp"
Else
Response.Redirect "index.asp"
End If
End If
%>
<html>
<body>
<form method="POST" action="index.asp">
<div align="center"><center><p><input type="password" name="pass" size="10"><br>
<input type="submit" value="Login"></p>
</center></div>
</form>
</body>
</html>
<%End If%>
page1.asp
<%
If Not Session("pass") Then Response.Redirect "index.asp"
%>
These are the few lines of code you need on top of the page. That's all.
|