当前位置: 移动技术网 > IT编程>开发语言>其他编程 > 如何对用户进行授权?

如何对用户进行授权?

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

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]

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

相关文章:

验证码:
移动技术网