| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 947 人关注过本帖
标题:[求助]这段用户登陆的代码怎么不行?
只看楼主 加入收藏
yanguorui
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-5-18
收藏
 问题点数:0 回复次数:13 
[求助]这段用户登陆的代码怎么不行?

conn.asp

<%
dim conn
set conn=Server.createobject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath("lanier_db.mdb")
If err.number<>0 then
Response.write("连接数据库时产生错误!")
Response.End
End if
%>



login.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>

<form method="post" action="check.asp">
用户名:<input type="text" name="userid" size="20">
密 码: <input type="text" name="pwd" size="20">
<input type="submit" name="submit1" value="登录">
<input type="reset" name="button1" value="清除">
</form>
</body>
</html>



check.asp

<!--# include file="conn.asp"-->
<%
Dim Rs,Sql,Userid,Pwd
Userid=Request.form("Userid") '提取login.asp页面的用户名;
Pwd=Request.form("pwd") '提取login.asp页面的密码;
Set Rs=Server.Createobject("adodb.recordset")
Sql="select * from login where userid='"&Userid&"' "
Rs.open sql,conn,1,1
If rs.eof and rs.eof then '判断用户名是否存在
Response.write "<script language=javascript>alert('用户不存在');history.go(-1);</script>"
Response.End
Elseif Rs("pwd")<>pwd then '判断密码是否正确
Response.write "<script language=javascript>alert('密码错误');history.go(-1);</script>"
Response.End
Else
Session("userid")=userid '把用户名写入session
Response.redirect("index.asp")
End if
%>

麻烦各位给看一下,急用!

[此贴子已经被作者于2007-6-15 9:46:24编辑过]

搜索更多相关主题的帖子: 代码 用户 登陆 
2007-06-15 09:43
xiapi
Rank: 1
等 级:新手上路
威 望:2
帖 子:305
专家分:0
注 册:2006-10-11
收藏
得分:0 
怎么不行了,是进不去,还是提示错误

没有什么能够阻挡,我对自由的向往,天马行空的生涯一颗心了无牵挂。
2007-06-15 09:56
SkyGull
Rank: 5Rank: 5
来 自:浙江杭州
等 级:贵宾
威 望:13
帖 子:839
专家分:324
注 册:2007-6-7
收藏
得分:0 
[CODE]If rs.eof and rs.eof then '判断用户名是否存在
Response.write "<script language=javascript>alert('用户不存在');history.go(-1);</script>"
Response.End
Else
if Rs("pwd")<>pwd then '判断密码是否正确
Response.write "<script language=javascript>alert('密码错误');history.go(-1);</script>"
Response.End
Else
Session("userid")=userid '把用户名写入session
Response.redirect("index.asp")
End If
End if[/CODE]
2007-06-15 10:23
yanguorui
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-5-18
收藏
得分:0 
进不去啊

2007-06-15 10:26
yanguorui
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-5-18
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册


2007-06-15 10:31
laigaoat2005
Rank: 4
等 级:业余侠客
帖 子:388
专家分:226
注 册:2007-4-5
收藏
得分:0 

还有的错误信息呢?

2007-06-15 10:58
yanguorui
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-5-18
收藏
得分:0 

就是只有这一些啊!


2007-06-15 14:26
SkyGull
Rank: 5Rank: 5
来 自:浙江杭州
等 级:贵宾
威 望:13
帖 子:839
专家分:324
注 册:2007-6-7
收藏
得分:0 
把显示友好HTTP错误的勾去掉
2007-06-15 14:27
SkyGull
Rank: 5Rank: 5
来 自:浙江杭州
等 级:贵宾
威 望:13
帖 子:839
专家分:324
注 册:2007-6-7
收藏
得分:0 
你怎么用8080啊
2007-06-15 14:28
恒天
Rank: 1
等 级:新手上路
威 望:2
帖 子:165
专家分:0
注 册:2007-6-1
收藏
得分:0 

conn.asp


<%
dim conn
set conn=Server.createobject("adodb.connection")
conn.open "Driver={Microsoft Access Driver (*.mdb)};defaultdir=;SQL="&Server.MapPath("lanier_db.mdb")
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "连接数据库时产生错误!"
Response.End
End If
%>

login.asp

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>

<form method="post" action="check.asp">
用户名:<input type="text" name="userid" size="20">
密 码: <input type="password" name="pwd" size="20">
<input type="submit" name="submit1" value="登录">
<input type="reset" name="button1" value="清除">
</form>
</body>
</html>

check.asp


<!--#include file="conn.asp"-->
<%
Dim Rs,Sql,Userid,Pwd
Userid=trim(Request.form("Userid")) '提取login.asp页面的用户名;
Pwd=trim(Request.form("pwd")) '提取login.asp页面的密码;
Set Rs=Server.Createobject("adodb.recordset")
Sql="select * from login where userid='"&Userid&"'"
Rs.open sql,conn,1,1
If rs.eof and rs.eof then '判断用户名是否存在
Response.write "<script language=javascript>alert('用户不存在');history.go(-1);</script>"
Response.End
Else
if Rs("pwd")<>pwd then '判断密码是否正确
Response.write "<script language=javascript>alert('密码错误');history.go(-1);</script>"
Response.End
Else
Session("userid")=userid '把用户名写入session
Response.redirect("index.asp")
end if
End if
%>

试试这个

2007-06-15 15:48
快速回复:[求助]这段用户登陆的代码怎么不行?
数据加载中...
 
   



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

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