Asp一起来写个留言板(二)
四.登录
前面说过了,登录即查询.主要看登录处理页面checklogin.asp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>检验登录</title>
</head>
<body>
<%
username=request.Form("username")
password=request.Form("userpwd")
'以下连接数据库,建立一个Connection对象实例db
Dim db
Set db=Server.CreateObject("ADODB.Connection")
db.Open "Dbq="&Server.Mappath("data.mdb")&";Driver={Microsoft Access Driver (*.mdb)}"
//查询SQL语句
strSql="Select * From user where username='"&username&"'and userpwd='"&password&"'"
set rs=db.execute(strsql)
if rs.eof then
response.Write "错误的用户名或密码"
else '成功
session("un")=username //存入session,以后页面判断权限调用
session("up")=password
response.Redirect("index.asp")//重定向到 首页
end if
set rs=nothing
%>
</body>
</html>
浙公网安备 33010602011771号