NEWSZW_HZH_BEGIN-->
manage.asp
' 登录页面 .
<%@ Language=VBScript %>
<html>
<body>
<form name="Login" method="Post" action="login.asp">
<input type="text" name="username" size="20"> 用户名 <br>
<input type="password" name="password" size="20"> 口令 <br>
<input type="submit" name="btnLogin" value=" 登录 ">
</form>
</body></html>
login.asp
' 验证在表单中输入的用户名和口令 .
<% Response.Buffer = True %>
<html>
<body>
<% Session("allow") = True %>
<%
UserName = Request.Form("username")
Password = Request.Form("password")
' 抓取表单内容 .
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open " 连接字符串 "
SQL = "Select * From tblLogin"
Set RS = MyConn.Execute(SQL)
If UserName = RS("UserName") AND Password = RS("Password") Then
' 如果匹配则显示要保护的页面 .
%>
----------------------------------------------------------------------------------------------------------------
' 此处放置要保护的页面的内容 .
----------------------------------------------------------------------------------------------------------------
<%
Else
Response.Redirect "http://HdhCmsTestintels.net/login.asp"
RS.Close
MyConn.Close
Set RS = Nothing
Set MyConn = Nothing
End If
%>
' 如果不匹配则返回登录页 , 让用户重新登录 .
</body></html>
好了,让我们来做最后的应用工作吧,把下面的代码加入需要保护的页面的最前面:
<%@ Language=VBScript %>
<% Response.Buffer = True %>
<% If session("allow") = False Then Response.Redirect "manage.asp" %>
[1]
NEWSZW_HZH_END-->查看更多关于如何制作一个安全的页面?_编程10000问_的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did27375