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
' 验证在表单中输入的用户名和口令.

<%@ Language=VBScript %>
<% 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://www.intels.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]

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com