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

ASP
对数据库中的记录用上一条下一条显示(二)
对数据库中的记录用上一条下一条显示(三)
完整的站点访问统计系统(一:数据库篇)
FIF小组ASP互动视频教程
关于ASP,ASP.NET,VB.NET里的MD5加密函数
ASP正则表达式详解
ASP中非数据库实现数据对象的定义及处理
编程爱好者的福音 让IIS6.0支持ASP
使用xml http为网站增加域名查询功能
用ASP实现支持附件的EMail系统
使用ADO.net将数据导出到Excel并提供下载
ASP实现图片上传
asp组件上传
ASPX页Web服务调用性能优化
asp实现语音上传
VBScript教程 第六课
VBScript教程 第三课
使ASP程序跨浏览器
四步讲解ASP中正则表达式的应用
ASP教程:深入认识学习ASP应用Cookies的技巧

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 42 ::
收藏到网摘: 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