当前位置: 代码网 > it编程>编程语言>其他编程 > 如何最大限度地实现安全登录功能?

如何最大限度地实现安全登录功能?

2024年05月19日 其他编程 我要评论
<%if not isempty(session("cust—id")) and len(session("cust—id"))>0 then' 用户登录后指向主页. response.r

<
if not isempty(session(
"cust—id")) and len(session("cust—id"))>0 then

' 用户登录后指向主页.
 response.redirect("navigation/dashbrd.asp")

 ' 在此添入真正的主页url.

end if

blogin = false
  

' 设置标志.
berror = false
if isempty(request(
"uid")) or len(request("uid")) = 0 or isempty(request("pwd")) or len(request("pwd")) = 0 then  

' 检查空字符.
  blogin = true
else

 

----------------------------------------------------------------------------------------------------------------
' 检验数据库保存密码表中是否有该用户.
"select from customer where cust—id=′ " request("uid") "′ and ′cust—pwd=′" request(″pwd″) ""
' 连接数据库,其中request(″uid″)request(″pwd″) 为本页html中表单中的用户名和密码的text.

  gbfound = false
----------------------------------------------------------------------------------------------------------------

  if not rscust.bof and not rscust.eof then
    gbfound = true
  end if

  if gbfound then
    session("cust—id") = rscust.fields("cust—id")
    ' session变量中记录有用的信息.此项为数据库中用户名.
    session("cust—pwd") = rscust.fields("cust—pwd")

' 此项为数据库中用户密码.
    session("power") = rscust.fields("power")

        ' 此项为数据库中用户权限,可选.

    ' rscust.activeconnection.execute ("update customer set cust—login = ′ " now "′ where cust_id = " session("cust—id") "")

' 更新最后登录时间,可选.

    response.redirect("navigation/dashbrd.asp")

        ' 真正主页url.
  else
    ′uid and password not found
    berror = true blogin = true
  end if

  rscust.close
   ' 关闭记录.
   mycn—login.close
  set mycn—login=nothing
 end if
>

 

----------------------------------------------------------------------------------------------------------------

' 登录页面.

<form name="login" action="default.asp" method="post" target="—top">

' html中加入form,并设为自发送页.action后面要接本页的url,这样,即使用户登录错误,在本页即可获得提示,而无须再返回前一页登录.

input name="uid" size="10"maxlength="10" style="height: 21px; width: 101px">

<input name="pwd"type="password" size="10" maxlength="10">

[1]

(0)

相关文章:

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

发表评论

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