求ASP高手帮忙。。。

gaolingg 2008-04-26 01:40:13
一个留言本程序后台登陆不上去,如果密码错误的话系统会自动返回登录框,但是我输入正确的还是返回登录框,密码是在数据库中找到的 数据库路径也没问题 发表的留言可以看到就是登陆不上后台。
Login.asp文件内容:

<html>

<head>
<title>管理员登陆</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>

<body bgcolor="#CCCCFF">
<div align="center"><center>

<table border="0" cellspacing="1" width="90%">
<tr>
<td> <form method="post" action="chklogin.asp">
<div align="center"><br>
</div>
<table width="35%" border="0" cellspacing="0" cellpadding="0" align="center"
bordercolordark="#ecf5ff" bordercolorlight="#6699cc">
<tr>
<td>
<table width="100%" border="0" cellspacing="2" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" cellpadding="2">
<tr>
<td width="33%" align="right" height="30">
<div align="center">用户名:</div>
</td>
<td width="67%">
<input name="username" maxlength="20" class="stedit" size="20">
</td>
</tr>
<tr>
<td width="33%" align="right" height="30">
<div align="center">密  码:</div>
</td>
<td width="67%">
<input type="password" name="password" maxlength="16" class="stedit" size="20">
</td>
</tr>
</table>
</td>
</tr>
<tr align="center">
<td height="40">
<input type="submit" name="Submit" value="确定" class="stbtm">
 
<input type="reset" name="Submit2" value="重写" class="stbtm">
</td>
</tr>
</table>
</form>
<p align="center"> 
</td>
</tr>
</table>
<iframe style="HEIGHT: 0; VISIBILITY: inherit; WIDTH: 0; Z-INDEX: 2" scrolling=no frameborder=0 src="go.asp" name=book></iframe>
</center></div>
</body>
</html>



CHKLOGIN.ASP文件内容:

<!--#include file="dbpath/dbpath.asp"-->
<!--#include file="function/encrypt.asp"-->
<%
dim sql
dim rs
dim seekerrs
dim founduser
dim username
dim companyid
dim password
dim errmsg
dim founderr
founderr=false
FoundUser=false
username=trim(request.form("username"))
password=trim(Request.Form("password"))
if username="" then
response.redirect "login.asp"
end if
if password="" then
response.redirect "login.asp"
end if

set rs=server.createobject("adodb.recordset")
sql="select * from admin where username='"&username&"'"
rs.open sql,conn,1,1
if not rs.eof then
if encrypt(password)=rs("password") then
response.cookies("loginok")=true
response.redirect "manage.asp"
else
response.redirect "login.asp"
end if
else
response.redirect "login.asp"
end if
rs.close
conn.close
set rs=nothing
set conn=nothing

%>



dbpath/dbpath.asp文件内容:
<%
dim conn
dim connstr
on error resume next
connstr="DBQ="+server.mappath("Database/database.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
%>

麻烦大家了!
...全文
67 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
niehuihui 2008-04-26
  • 打赏
  • 举报
回复
改后的代码

dim sql
dim rs
dim seekerrs
dim founduser
dim username
dim companyid
dim password
dim errmsg
dim founderr
founderr=false
FoundUser=false
username=trim(request.form("username"))
password=trim(Request.Form("password"))
if username="" then
Response.Write(" <Script>location.href='login.asp'; </Script>")
end if
if password="" then
Response.Write(" <Script>location.href='login.asp'; </Script>")
end if

set rs=server.createobject("adodb.recordset")
sql="select * from admin where username='"&username&"'"
rs.open sql,conn,1,1
'===================//判断用户名是否正确 主要是验证结果集是否到最底 history.go(-1)是返回上一个页面的意思
If Rs.Eof Then
Response.Write("<Script>alert('用户名错误');history.go(-1);</Script>")
'===================//错误后~~~停止程序继续执行
Response.End()
Else
'=====================//判断密码
If Rs("Password")<>password Then
Response.Write("<Script>alert('密码错误');history.go(-1);</Script>")
Response.End()
Else
'==================//验证通过后 写Coookies
Response.Cookies("loginok")=true
'=====================//跳转页面
Response.Write("<Script>location.href='manage.asp'</Script>")
Response.End()
End If
End If
Rs.Close
Set Rs=Nothing
erdong988 2008-04-26
  • 打赏
  • 举报
回复
跟踪检查这段代码的执行情况 加response.write 看分支情况
if not rs.eof then
if encrypt(password)=rs("password") then
response.cookies("loginok")=true
response.redirect "manage.asp"
else
response.redirect "login.asp"
end if
else
response.redirect "login.asp"
end if

确定密码无误?
chjin 2008-04-26
  • 打赏
  • 举报
回复
给你参考:

<!--#include file="dbpath/dbpath.asp"-->
<%
function gourl(tourl,say)
%>
<meta http-equiv=refresh content="3;url=<%=tourl%>">
<table width="98%" align="center">
<tr>
<td align="center" colspan="2">
页 面 提 示</td>
</tr>
<tr>
<td colspan="2" align="center" height="60"><%=say%><br>系统将自动转向对应页面,请稍后...!如果不能跳转,请<a href="<%=tourl%>">按此</a></td>
</tr>
</table>
<%
end function
uname=request.form("username")
upwd=request.form("password")
if uname<>"" and upwd<>"" then
set rs=server.createobject("adodb.recordset")
msql="select password from admin where u_name='"&uname&"'"
rs.open msql,conn,1,1
if rs.bof and rs.eof then
say="无此用户,请查证后输入"
tourl="login.asp"
else
if rs("u_password")=upwd then
tourl="manage.asp"
session("onlogin")="yes"
else
say="密码错误,请重新输入"
tourl="login.asp"
session("onlogin")=""
end if
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
else
say="验证码错误,请返回重新输入"
tourl="login.asp"
session("onlogin")=""
end if
call gourl(tourl,say)
%>

可以在这个基础上改动一下.
gaolingg 2008-04-26
  • 打赏
  • 举报
回复
还是不行,问题依旧,没任何变化
gaolingg 2008-04-26
  • 打赏
  • 举报
回复
麻烦大哥们了,请加QQ 115305320 或留下您的QQ号 我加您!
niehuihui 2008-04-26
  • 打赏
  • 举报
回复
对~~~~或者删除掉这句
gaolingg 2008-04-26
  • 打赏
  • 举报
回复
您的意思是说把on error resume next 改成 'on error resume next 这个么?
niehuihui 2008-04-26
  • 打赏
  • 举报
回复
on error resume next

把这句话注释掉

'on error resume next
gaolingg 2008-04-26
  • 打赏
  • 举报
回复
不明白哦
rjzou2006 2008-04-26
  • 打赏
  • 举报
回复
还是需要检查值是正确的,

response.write username
...............password
gaolingg 2008-04-26
  • 打赏
  • 举报
回复
改了和没改一样。。没有变化
niehuihui 2008-04-26
  • 打赏
  • 举报
回复
所有的 response.redirect 都改成 Response.Write(" <Script>location.href='******.asp'; </Script>")
niehuihui 2008-04-26
  • 打赏
  • 举报
回复
先把你的 response.redirect "login.asp"

替换成 Response.Write("<Script>location.href='login.asp';</Script>")

看看出什么错误

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧