
Untitled
By: a guest on
May 9th, 2012 | syntax:
None | size: 1.40 KB | hits: 14 | expires: Never
ASP password protect improvement
<%
needAuthentication = True
If Request.Form.Count > 0 Then
If Request.Form("username") <> "jon" Or Request.Form("password") <> "secret" Then
' Redirect to another URI
Response.Redirect("/")
Response.End
End If
needAuthentication = False
End If
%>
<html>
<body>
<%
If needAuthentication Then
%>
<form method="post" action="thenameofthepage.asp">
<div>Username: <input type="text" name="username" /></div>
<div>Password: <input type="text" name="password" /></div>
<div><input type="submit" value="Submit" /></div>
</form>
<%
Else
%>
<p>Page content here</p>
<%
End If
%>
</body>
</html>
<%
needAuthentication = True
authenticationFailed = False
If Request.Form.Count > 0 Then
If Request.Form("password") <> "secret" Then
authenticationFailed = True
End If
needAuthentication = False
End If
%>
<html>
<body>
<%
If needAuthentication Then
%>
<form method="post" action="passwordtest.asp">
<div>Password: <input type="text" name="password" /></div>
<div><input type="submit" value="Submit" /></div>
</form>
<%
Else
%>
<p>Page content here</p>
<%
End If
%>
<%
If authenticationFailed Then
%>
<script type="text/javascript">
alert("Invalid login");
</script>
<%
End If
%>
</body>
</html>
<%
If authenticationFailed Then
%>
<script type="text/javascript">
alert("Invalid login");
</script>
<%