用密码保护页面 (II)
程序员文章站
2022-07-07 19:39:11
英文原文 现在我们创建查询语句,可以验证在表单中输入的内容是否与中的内容相一致。 <%@ language=vbscript %><% response.buff...
英文原文
现在我们创建查询语句,可以验证在表单中输入的内容是否与中的内容相一致。
<%@ 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 "https://www.yourdomain.com/login."
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 "https://www.yourdomain.com/login."
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
上一篇: C语言-数组的定义、初始化和使用
下一篇: 一个免费的邮件列表源程序(二)