当前位置: 代码网 > it编程>编程语言>其他编程 > 如何对用户进行授权?

如何对用户进行授权?

2024年05月19日 其他编程 我要评论
authenticate.asp<%dim urlurl = request.querystring' 获得url. %> <html><body><form

authenticate.asp
<%
dim url
url = request.querystring

' 获得url.
%>

<html>
<body>
<form method=post action="/validate.asp">
  <input type=hidden name="url" value="<%=url%>">
 '
url保存到一个隐藏变量中.
 
用户名:
  <input type=text name="txtname">
 
口令:
  <input type=password name="txtpassword">

  <input type=submit>
</form>
</body></html>
   
再用validate.asp文件获取传递给它的信息,从数据库中读取用户名和口令,以判断是否给用户授权。

validate.asp
<%
dim strusername, strpassword
strusername = request.form("txtname")
strpassword = request.form("txtpassword")
'
从表单中读取用户名和口令.


'
建立数据库连接...

dim strsql
strsql = "select * from validusers where username = " & _
    strusername & " and password = " & _
    strpassword

' 进行sql查询.

dim rs
set rs = conn.execute(strsql)

if rs.eof then

' 如果recordset不为空, 则用户名有效.
session("bolauthenticated") = true

' bolauthenticated 设为true.

    response.redirect request.form("url")

   ' 将用户传递到来过的url.
else
    response.redirect "/notvalidated.asp 

  ' 否则用户无权访问,将用户传递到一个错误提示页面.
end if
%>

[1]

(0)

相关文章:

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

发表评论

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