当前位置: 代码网 > it编程>编程语言>其他编程 > 如何实现强制登录?

如何实现强制登录?

2024年05月19日 其他编程 我要评论
security.asp<%bloggedin = (len(session("username")) > 0) if brequirelogin then' 要求登录. if not b

security.asp

<%

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]

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com