|
Code Snippets Needed
to Password Protect
Portions of a Webpage
Login Code Snippet
Hover your cursor over
the script, and triple-click to highlight the
script. Copy (Ctrl+C) the
script to the
clipboard. Go to your
login.asp
page and, in Code view, paste it
(Ctrl+V).
<%
Username="teacher" //NEXT,CHANGE THE USERNAME HERE
Password="risd" //NEXT,CHANGE THE PASSWORD HERE AS WELL
' if any of the variables do not match, create error message
if Request.Form("login") <> Username or Request.Form("password")
<> Password then
MsgErr = ""
Response.Write MsgErr
' if correct, set the session variable and proceed
Else
Session("someStringValue") = true
' redirect
If Len(Request("requester")) > 0 Then
Response.Redirect (Request("requester"))
Else
Response.Redirect "protected.asp"
End if
End if
%>
<html>
<head>
<title>Results -- Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>
<body bgcolor="#FFFFFF" style="text-align: left">
<div align="center">
<table border="0" cellpadding="0" style="border-collapse:
collapse" width="90%" id="table1">
<tr>
<td>
<FORM ACTION="login.asp" METHOD="post">
<input TYPE="hidden" NAME="requester" VALUE="<%=Server.HtmlEncode(Request("requester"))%>">
<div align="center">
<table border="0" cellpadding="0" style="border-collapse:
collapse" width="90%" id="table2">
<tr>
<td align="left">
<h3 align="left">Login</h3>
<TABLE BORDER=0 id="table3">
<TR>
<TD ALIGN="right">
<p align="left">Username:</TD>
<TD>
<p align="left"><INPUT TYPE="text" NAME="login" size="10"
VALUE=''/></TD>
</TR>
<TR>
<TD ALIGN="right">
<p align="left">Password:</TD>
<TD>
<p align="left"><INPUT TYPE="password" NAME="password" size="10"
VALUE=''/></TD>
</TR>
<TR>
<TD>
<p align="left"> </TD>
<TD>
<p align="left"></TD>
</TR>
<TR>
<TD align="left">
<INPUT TYPE="submit" VALUE="Submit" style="font-family: Times
New Roman; font-size: 12pt"/></TD>
<TD>
<p align="left"></TD>
</TR>
</TABLE>
<p> </td>
</tr>
</table>
</div>
</FORM>
<p> </td>
</tr>
</table>
</div>
</body>
</html> |
|