如何实现强制登录?_编程10000问

security.asp<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />


<%

bLoggedIn = (len(session("UserName")) > 0)

if bRequireLogin then

' 要求登录.

   if Not bLoggedIn then   

     response.redirect "login.asp?comebackto=" & _

     request.servervariables("script_name") & "?" & _

      ' 如果没注册,请注册.

     server.urlencode(request.querystring)

   end if

end if

%> 

 

login.asp


<%

if request("comebackto") <> "" then

   sReferer = request("comebackto")

   sGoBackTo = "?" & request.querystring

end if

if request("cmdLogin") <> "" then

   sUserName = request("txtUserName")

   sPassword = request("txtPassword")

   ' 提交注册.

   if sUserName = "bill" And sPassword = "gates" then

     bLoginSuccessful = True

     ' 验证帐号和密码.

   end if

   session("UserName") = sUserName

   if sReferer = "" then

     response.redirect "index.asp"

     ' 登录成功,到用户请求页.

   else

     response.redirect sReferer

     ' 如果没填写,重定向到登录页或其他约定的页.

end if

else

%>

   <form action="login.asp<%=sGoBackTo%>" method="post">

     <input type="text" name="txtUserName"><br>

     <input type="password" name="txtPassword"><br>

     <input type="submit" name="cmdLogin"><br>

   </form>

    ' 显示登录.

<%

end if

%>

 

testpage.asp


<%

   bRequireLogin = True

%>

<!--#include file="security.asp"-->

' 将 bRequireLogin设为真,放到 security.asp 中.

 

[1]

时间: 2024-09-13 21:40:13

如何实现强制登录?_编程10000问的相关文章

怎样避免直接在地址栏敲入URL即可绕过登录页的错误?_编程10000问

第一个办法:用两个文件来解决这个问题:userandpwd.asp和secretarticle.asp.前者只负责提供输入用户名和密码,由后者来完成验证工作.这样即使知道了asppwdrst.asp 所在的 URL,也决不会看到什么内容的. userandpwd.asp < html > < body > < form name="form1"action= "secretarticle.asp" method_ ="POST

如何用Cookie进行登录验证?_编程10000问

login.htm请注册登录随风起舞<FORM ACTION="checklogin.asp" METHOD="POST">    电子邮件: <input TYPE="Text" NAME="email" SIZE="40">    密码: <input TYPE="Password" NAME="Password" SIZE=&quo

如何决定是否将登录内容保存到Cookie里?_编程10000问

login.htm<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> <% @ Language=javascript %><%if (Request.Cookies("SavedLogin").HasKeys) {    Response.Redirect("checklogin.asp?Cookie=1")}%&

如何最大限度地实现安全登录功能?_编程10000问

<%if not IsEmpty(Session("cust-id")) and Len(Session("cust-id"))>0 then<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> ' 用户登录后指向主页. Response.Redirect("navigation/dashbrd.asp"

ASP问答集_编程10000问

问:为什么我的记录集的RecordCount值总是返回-1? 答:你应当使用这种模式来打开存取数据库的记录集:   rec.open strSQL,conn,1,1   其中的strSQL是操作数据库的SQL语句;conn是联接数据库的Connection 变量. 问:我在ASP脚本中写了很多的注释,这会不会影响服务器处理ASP文件的速度? 答:经国外技术人员测试,带有过多注释的ASP文件整体性能仅仅会下降0.1%,也就是说基本上不会影响到服务器的性能下降的. 问:我需不需要在每个ASP文件的开

如何实现某些页面只让特定的用户浏览?_编程10000问

global.asp     <script language=vbscript runat=server> <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> sub Session_onstart session("register")="false" ' 记录用户成功登录的信息. session("logn

如何取回已忘记的密码?_编程10000问

forget.asp<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> ' 申请. <html> <head> <title>闪亮日子之用户密码核实</title> </head> <div align="center"><center> <table border

网上考试设计思路是怎样的?_编程10000问

global.asa < script LANGUAGE=VBScript RUNAT=Server > Sub Application_OnStart    dbPath = "DBQ=" & Server.Mappath("onlinetest.mdb")    dbConnectionString =  "DRIVER={Microsoft Access Driver (*.mdb)}; " & dbPath  

如何创建Word文件?_编程10000问

creatdoc.asp<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> <!DOCTYPE html PUBLIC "-//W3C/Dtd html 3.2 Final//EN"><head><title>星河影动之创建Word文件</title><META HTTP-EQUIV="Re