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 ' 如果匹配則顯示要保護(hù)的頁面. %> ---------------------------------------------------------------------------------------------------------------- ' 此處放置要保護(hù)的頁面的內(nèi)容. ---------------------------------------------------------------------------------------------------------------- % Else Response.Redirect "http://www.intels.net/login.asp" RS.Close MyConn.Close Set RS = Nothing Set MyConn = Nothing End If %> ' 如果不匹配則返回登錄頁,讓用戶重新登錄.
/body>/html>
好了,讓我們來做最后的應(yīng)用工作吧,把下面的代碼加入需要保護(hù)的頁面的最前面: %@ Language=VBScript %> % Response.Buffer = True %> % If session("allow") = False Then Response.Redirect "manage.asp" %>