四.登录

前面说过了,登录即查询.主要看登录处理页面checklogin.asp

 

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

相关文章: