如下为你输入用户名和密码提交表单后判断登陆代码,红色部分是写入session
<%
dim admin,password
admin=request.form("admin")
password=request.form("password")
set rs=server.createobject("adodb.recordset")
sql="select * from guanli where admin='"&admin&"'"
rs.open sql,conn,1,1
if rs.eof then
response.write "<script>alert('登录失败');history.back();</script>"
response.end
else
if rs("password")<>password then
response.write "<script>alert('登录失败');history.back();</script>"
response.end
end if
session("admin")=admin
response.redirect("dlcg.asp")
end if
%>
在你要防止用户通过地址栏输入直接进入网站的页面顶端加上<!--#include file="dlck.asp"-->
dlck.asp代码为
%
if
session("admin")=""
then
response.write
"<script>alert('你还没登陆.或者登陆超时.请重新登陆.');top.location.href='index.asp';</script>"
response.end
end
if
%>