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

ASP
无刷新随时取得用户当前活动信息
编写一个asp代码执行器
利用XSL和ASP在线编辑XML文档
ASP应用:用stream读文件
如何用Asp动态生成xml文件
实例演练ASP+XML编程(1)
实例演练ASP+XML编程(2)
实例演练ASP+XML编程(3)
实例演练ASP+XML编程(4)
用文件写入建立简单的网上调查
轻松打造ASP计数器
用纯ASP代码实现图片上传
“在线访客”的制作方法
如何开发基于ASP的FLASH MX在线图象浏览器
ASP图形计数器设计详解
ASP+VML+DB实现投票统计项目
ASP中DLL的调试环境配置全攻略
一个实用的FSO-实时统计在线人数
ASP实现语音分时问候
利用ASP打造网站论坛DIY

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


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