欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-04-15 09:25:38
<%if not isempty(session("cust—id")) and len(session(...

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