用密码保护页面 (II)
敬业的IT人
互联网
佚名
2008-4-14 17:24:55
英文原文
现在我们创建查询语句,可以验证在表单中输入的内容是否与数据库中的内容相一致。
<%@ 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
现在我们创建查询语句,可以验证在表单中输入的内容是否与数据库中的内容相一致。
<%@ 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
- 最新文章
- 用密码保护页面 (III)[04-14]
- 简单的文件目录浏览源程序[04-14]
- 使用VB编写纯ASP程序[04-14]
- ASP中的函数应用方法及应用举例(一)[04-14]
- ASP中的函数应用方法及应用举例(二)[04-14]
- 完整的访问统计系统(一:数据库篇)[04-14]
- 相关文章
- 用密码保护页面 (III)[04-14]
- 产生随机密码的函数[04-14]
- 用ASP技术编制隐藏用户密码程序[04-14]
- 产生密码,记录到数据库,然后发送给用户。[04-14]
- 加密处理使密码更安全[04-14]
- PKCS #5: 基于口令的密码系统规范 版本2.0[03-18]
