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

所属分类: 网络编程 / 编程10000问 阅读数: 624
收藏 0 赞 0 分享

<
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 赞 0 分享

怎样给文件加密最安全?

怎样给文件加密最安全?
收藏 0 赞 0 分享

如何用Access加密页面?

如何用Access加密页面?
收藏 0 赞 0 分享

为什么用磁盘序列号加密过的代码不能被复制安装?

为什么用磁盘序列号加密过的代码不能被复制安装?
收藏 0 赞 0 分享

如何根据用户银行帐户余额的多少进行显式的提交或终止?

如何根据用户银行帐户余额的多少进行显式的提交或终止?
收藏 0 赞 0 分享

如何获知所有的Cookie?

如何获知所有的Cookie?
收藏 0 赞 0 分享

如何提示用户打开Cookie?

如何提示用户打开Cookie?
收藏 0 赞 0 分享

如何刪除客户端的Cookies?

如何刪除客户端的Cookies?
收藏 0 赞 0 分享

如何让用户再次访问我的网站时不需再提交相关信息?

如何让用户再次访问我的网站时不需再提交相关信息?
收藏 0 赞 0 分享

如何用Cookie进行登录验证?

如何用Cookie进行登录验证?
收藏 0 赞 0 分享
查看更多