您现在的位置: 无忧电子商务网 >> 信息学院 >> 程序开发 >> asp >> 正文

利用ASP给主页加密之二

作者:佚名    信息学院来源:整理    点击数:    更新时间:2008-1-24 我要参与讨论

  利用ASP给主页加密

我们的目的是:

  *验证用户是否经过授权并根据结果设置相应的验证状态

  *如果用户是经过授权的,验证状态置1

  *如果用户是没有授权的,验证状态置0

下面显示的是verify.asp页的代码,你可以根据实际情况作一些相应的修改。

< %

’ Create a command object. This object serves to run our queries

Set Cm = Server.CreateObject(“ADODB.Command”)

’ Specify the system DSN path

Cm.ActiveConnection =“LoginDSN”

’ Now it’s time for the query. We need to check the user information

’ against the table tUsers

Cm.CommandText=“SELECT * FROM tUsers WHERE ”& _

“UserName=’”& Request.Form(“UserName”) &“’ AND ”& _

“UserPassword=’” & Request.Form(“UserPassword”) & “’”

’ Set the query type. 1 means it is a SQL statement

Cm.CommandType = 1

’ Retrieve the results in a recordset object

Set Rs = Cm.Execute

’ We now check if the user is valid. If user is valid, the recordset MUST

’ haverecord. Otherwise it is empty. If user exists, we set authentication

’ status to 1 and send the user to appropriate page, say welcome.asp.

’ Else send the user back to login.asp

If Rs.EOF Then

Session(“Authenticated”) = 0

Response.Redirect (“login.asp”)

Else

Session(“Authenticated”) = 1

Response.Redirect (“welcome.asp”)

End If

% >
步骤6:检查验证状态

  这是我们系统中的一个重要的部分。我们要在每个受到保护的页面上,检查用户的验证状态。这个做起来很简单。只要检查用户的验证状态是否为1即可,如果不是1则把用户重新送到login.asp页。示例

[1] [2] 下一页

在google里搜索更多利用ASP给主页加密之二

Google
Web www.51ec.org
  • 上一篇信息学院:

  • 下一篇信息学院:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    我来说两句 对此文章发表了评论
      昵 称: *必填    ·注册用户·
      评 分: 1分 2分 3分 4分 5分     严禁发表危害国家安全、政治、黄色淫秽等内容的评论,用户需对自己在使用本网站服务过程中的行为承担法律责任。本站管理员有权保留或删除评论内容,评论内容只代表机友个人观点,与本网站立场无关。  
    评 论
    内 容

     
    评论列表 (最新 评论仅限网友观点!)

    供求信息




    | 设为首页 | 加入收藏 | 关于我们 | 广告服务 | 联系方式 | 友情链接 | 版权申明