剑网三荻花圣殿全成就:用ASP做一个后台登录页--天心

来源:百度文库 编辑:偶看新闻 时间:2024/04/30 00:28:45
作者:天心
manage.asp' 登录页面
<%@ Language=VBScript %>



用户名

口令







login.asp' 验证在表单中输入的用户名和口令
<%@ Language=VBScript %>
<% Response.Buffer = True %>


<% Session("allow") = True
UserName = Request.Form("username")
Password = Request.Form("password")
' 抓取manage.asp表单内容
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
RS.Close
MyConn.Close
Set RS = NothingSet MyConn = Nothing
Response.Redirect "login.asp"
' 如果不匹配则返回登录页,让用户重新登录
End If%>






好了,让我们来做最后的应用工作吧,把下面的代码加入需要保护的页面的最前面:
<%@ Language=VBScript %>
<% Response.Buffer = True %>
<% If session("allow") = False Then '是在登陆是做判断用的
Response.Redirect "manage.asp"
end if%>
这回能看明白了吧