当前位置: 移动技术网 > IT编程>开发语言>其他编程 > 如何最大限度地实现安全登录功能?

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

2017年12月08日  | 移动技术网IT编程  | 我要评论

<
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]

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网