男人有妊娠纹是为什么:提示:数据库连接错误

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/27 14:32:53
我在网上down了一个程序,测试了一下.前台可以访问数据库,后台无法登陆.前台可以注册数据库中的其他表,而admin表不知道为什么下面程序登陆时无法进去.希望各位高手能够解决 谢谢.
这是conn.asp文件
<%

db="../Databases/myszw.mdb" '数据库文件位置
on error resume next
connstr="DBQ="+server.mappath(""&db&"")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
sub CloseConn()
conn.close
set conn=nothing
end sub

%>
这是admin_chklogin.asp
<%@language=vbscript codepage=936 %>
<!--#include file="Conn.asp"-->
<!--#include file="Inc/Config.asp"-->
<!--#include file="inc/md5.asp"-->

<%
dim sql,rs
dim username,password,CheckCode
username=replace(trim(request("username")),"'","")
password=replace(trim(Request("password")),"'","")
CheckCode=replace(trim(Request("CheckCode")),"'","")
if FoundErr<>True then
password=md5(password)
set rs=server.createobject("adodb.recordset")
sql="select * from user where username='" & username & "' and password='" & password & "'"
rs.open sql,conn,1,3
ErrMsg=rs("username").value
if rs.bof and rs.eof then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
else
if password<>rs("password") then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
else
RndPassword=GetRndPassword(16)
rs("LastLoginIP")=Request.ServerVariables("REMOTE_ADDR")
rs("LastLoginTime")=now()
rs("LoginTimes")=rs("LoginTimes")+1
rs("RndPassword")=RndPassword
rs.update
session.Timeout=SessionTimeout
session("AdminName")=rs("username")
session("AdminPassword")=rs("Password")
session("RndPassword")=RndPassword
rs.close
set rs=nothing
call CloseConn()
Response.Redirect "default.asp"
end if
end if
rs.close
set rs=nothing
end if
if FoundErr=True then
call WriteErrMsg()
end if
call CloseConn()

'****************************************************
'过程名:WriteErrMsg
'作 用:显示错误提示信息
'参 数:无
'****************************************************
sub WriteErrMsg()
dim strErr
strErr=strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
strErr=strErr & "<link href='style.css' rel='stylesheet' type='text/css'></head><body>" & vbcrlf
strErr=strErr & "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbcrlf
strErr=strErr & " <tr align='center'><td height='22' class='title'><strong>错误信息</strong></td></tr>" & vbcrlf
strErr=strErr & " <tr><td height='100' class='tdbg' valign='top'><b>产生错误的可能原因:</b><br>" & errmsg &"</td></tr>" & vbcrlf
strErr=strErr & " <tr align='center'><td class='tdbg'><a href='Login.asp'><< 返回登录页面</a></td></tr>" & vbcrlf
strErr=strErr & "</table>" & vbcrlf
strErr=strErr & "</body></html>" & vbcrlf
response.write strErr
end sub

%>

密码是md5加密的
程序思路不错,还+了随机的密码。提高了安全性
你登陆的提示是密码错误么?
如果你正确登陆应该不会有什么问题。