| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 475 人关注过本帖
标题:[求助]用户登录的问题!
只看楼主 加入收藏
无心
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2005-3-15
收藏
 问题点数:0 回复次数:2 
[求助]用户登录的问题!

自己写了一个用户登录的程序,但却不能实现,自己找过但不能解决,特来请哪位高手帮忙指点下,看哪里错了.

<% "登录页面
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>密&nbsp;&nbsp;码:
<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"
%>

搜索更多相关主题的帖子: 用户 登录 
2006-03-31 16:15
w374jd
Rank: 1
等 级:新手上路
帖 子:47
专家分:0
注 册:2006-4-3
收藏
得分:0 

试试这个


<%
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="?action=check">
<table width=170 cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="center" class="a1">用户登录:</td>
</tr>
<tr>
<td align="center" class="a1">
<table width="75%" border="00" cellspacing="0" cellpadding="0">
<tr>
<td valign=center>用户名:
<input size=8 name="user_name" maxlength="10"> </td>
</tr>
<tr>
<td width=100% valign=top>密&nbsp;&nbsp;码:
<input type=password size=8 name="user_pwd" maxlength='16'> </td>
</tr>
<tr>
<td align=right><a href="userReg.asp"><img src="images/reg.gif" width=39 height=25 border=0></a>
<input name="image" type="image" src="images/login.gif" width="39" height="25" border="0">
</td>
</tr>
<tr>
<td align=left> <a href="userReg.asp"> </a> </td>
</tr>
</table>
</td>
</tr>
</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
%>

<% if request.querystring("action")="check" then
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& "'"
rs.open strSQL,conn,1,3
if rs.eof ans rs.bof then
response.write "无此人"
response.end
elseif rs("user_pwd")<>user_pwd then
response.write "密码错误"

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"
end if
%>


域名注册/空间租用/网站制作/ASP编程开发/平面设..有意者,请联系:0429-8994637 QQ:70074004
2006-04-03 14:32
无心
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2005-3-15
收藏
得分:0 
谢谢!

因为把心给了你,所以我无心.
2006-05-25 14:32
快速回复:[求助]用户登录的问题!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011336 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved