自己写了一个用户登录的程序,但却不能实现,自己找过但不能解决,特来请哪位高手帮忙指点下,看哪里错了.
<% "登录页面
response.buffer=true
dim conn,connstr
on error resume next
connstr="driver={Microsoft Access Driver (*.mdb)};DBQ=" & server.mappath("data/data.mdb")
set conn=Server.CreateObject("ADODB.Connection")
conn.open connstr
if request.cookies("user_name")="" then %>
<form method="post" action="4.asp">
<table width=170 cellspacing="0" cellpadding="0" border="0">
<tr><td align="center" class="a1">用户登录:
<tr><td>
<table width=100% bgcolor=white cellpadding=0" cellspacing="0">
<tr><td height="15">
<tr>
<td valign=center>用户名:
<input size=8 name="user_name" maxlength="10">
<tr> <td width=100% valign=top>密 码:
<input type=password size=8 name="user_pwd" maxlength='16'>
<table width=100% align=center bgcolor=white> <tr>
<td align=right><input type="image" src="images/login.gif" width="39" height="25" border="0">
<td align=left> <a href="userReg.asp"><img src="images/reg.gif" width=39 height=25 border=0> </a>
</table>
</table>
</form>
<%
else
dim user_name
user_name=request.cookies("user_name")
set rs=server.createobject("ADODB.Recordset")
strSQL="select * form user where user_name='" &trim(user_name)& "'"
rs.open strSQL,conn,1,1
%>
<table width=170 cellspacing=0 cellpadding="0">
<tr>
<td align=center class=a1>欢迎您:</td>
</tr>
<tr><td>
<table width=100% bgcolor=white cellpadding="0" cellspacing="0">
<tr><td rowspan="4"><img src="<% =rs("user_pic") %>" border="0">
<tr><td align="center"><% =rs("user_name") %>
<tr><td align="center"><% =rs("user_sex") %>
<tr>
<td align="center">这是您第
<% =rs("user_logtime") %>
次登录.
</table>
</table>
<%
rs.close
set rs=nothing
end if
%>
<% "此为验证
dim strSQL,login_flag
user_name=trim(request.form("user_name"))
user_pwd=trim(request.form("user_pwd"))
set rs=server.createobject("ADODB.recordset")
strSQL="select * from user where user_name='" &user_name& "'"
strSQL=strSQL & "and user_pwd='" &user_pwd& "'"
rs.open strSQL,conn,1,3
if rs.eof=true then
login_flag=false
else
login_flag=true
end if
if login_flag=flase then
response.cookies("user_name")=""
msgbox "错误!用户名或密码错误!"
else
rs("user_logtime")=rs("user_logtime")+1
rs.update
response.cookies("user_name")=rs("user_name")
end if
rs.close
set rs=nothing
response.redirect "4.asp"
%>