用密码保护页面 (II)
程序员文章站
2022-03-30 09:59:32
英文原文 现在我们创建查询语句,可以验证在表单中输入的内容是否与中的内容相一致。 <%@ 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
上一篇: HCIE第一天复习(交换部分)
下一篇: 课时21.img标签(掌握)