欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

如何更好地保护我的网页?

程序员文章站 2022-10-28 10:50:09
main.htm

main.htm

<html>

<body>

<form action="login.asp" method="post">

<input type="text" name="username" size="20"> 账号<br>

<input type="password" name="password" size="20"> 密码<br>

<input type="submit" value="进入">

</form>

</body></html>

 

login.asp

<%@language=vbscript%>

<%response.buffer = true%>

<html>

<body>

<%

username = request.form("username")

password = request.form("password")

set myconn=server.createobject("adodb.connection")

myconn.open "provider={microsoft access driver (*.mdb)};

dbq=d:\suifengqiwu\databases\test.mdb"

sql = "select * from tbllogin"

set rs = myconn.execute(sql)

 

if username = rs("username") and password = rs("password") then

  session("allow") = true

< !-----连接保护的页面------->

else

  response.redirect "main.asp"

  rs.close

  myconn.close

  set rs = nothing

  set myconn = nothing

end if

%>

</body></html>

    做好了上面两个程序,再完善一下外围:把global.asa中的session_onstart加上 session("allow") = false 语句,再在要保护的网页中加入下面的语句:

<% @language=vbscript %>

<% response.buffer = true %>

<% if session("allow") = false then response.redirect "main.asp" %>

[1]