当前位置: 首页 > 图文教程 > 网络编程 > ASP > 用密码保护页面 (II)

ASP
用密码保护页面 (II)
用密码保护页面 (III)
简单的文件目录浏览源程序
ASP中的函数应用方法及应用举例(一)
ASP中的函数应用方法及应用举例(二)
完整的访问统计系统(一:数据库篇)
完整的访问统计程序(二 程序篇)
完整的访问统计程序(三 应用篇)
一个提供用户输入时期的绝好程序之(一)
一个提供用户输入时期的绝好程序之(二)
构建你的网站新闻自动发布系统之五
构建你的网站新闻自动发布系统之六
完整的访问统计程序(二 程序篇)
完整的访问统计程序(三 应用篇)
ASP环境下邮件列表功能的实现 (一)
ASP环境下邮件列表功能的实现 (二)
ASP环境下邮件列表功能的实现 (三)
ASP环境下邮件列表功能的实现 (四)
ASP进阶之文章在线管理更新(1)
ASP进阶之文章在线管理更新(2)

ASP 中的 用密码保护页面 (II)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 31 ::
收藏到网摘: n/a

  英文原文


现在我们创建查询语句,可以验证在表单中输入的内容是否与数据库中的内容相一致。

<%@ Language=VBScript %>
<% Response.Buffer = True %>

<HTML>
<BODY>

<% Session("allow") = True %>

<%
UserName = Request.Form("username")
Password = Request.Form("password")
'grab the form contents

Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "your connection string here"

SQL = "Select * From tblLogin"
Set RS = MyConn.Execute(SQL)

If UserName = RS("UserName") AND Password = RS("Password") Then
'if there is a match then show the page
%>


Put the contents of your page here.

<%
Else
Response.Redirect "http://www.yourdomain.com/login.asp"
RS.Close
MyConn.Close
Set RS = Nothing
Set MyConn = Nothing
End If
%>
'if there was no match then make the visitor try again to login.

</BODY>
</HTML>


把含上述代码的文件命名为login.asp