- 豆豆staR
-
分类: 电脑/网络 >> 程序设计 >> 其他编程语言
问题描述:
[url=zhidao.baidu/css/normal.css]<%@language=vbscript codepage=936 %>
<!--#include file="conn"-->
<!--#include file="md5"-->
<%
dim sql,rs
dim username,password,CheckCode
username=replace(trim(request("username")),""","")
password=replace(trim(Request("password")),""","")
CheckCode=replace(trim(Request("CheckCode")),""","")
if UserName="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名不能为空!</li>"
end if
if Password="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>密码不能为空!</li>"
end if
if CheckCode="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>验证码不能为空!</li>"
end if
if session("CheckCode")="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>你登录时间过长,请重新返回登录页面进行登录。</li>"
end if
if CheckCode<>CStr(session("CheckCode")) then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>您输入的确认码和系统产生的不一致,请重新输入。</li>"
end if
if FoundErr<>True then
password=md5(password)
set rs=server.createobject("adodb.recordset")
sql="select * from admin where password=""&password&"" and username=""&username&"""
rs.open sql,conn,1,3
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
rs("LastLoginIP")=Request.ServerVariables("REMOTE_ADDR")
rs("LastLoginTime")=now()
rs("LoginTimes")=rs("LoginTimes")+1
rs.update
session("admin")=rs("username")
session("purview")=rs("purview")
rs.close
set rs=nothing
call CloseConn()
Response.Redirect "main"
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 & "<><head><title>错误信息</title><meta -equiv="Content-Type" content="text/; charset=gb2312">" & vbcrlf
strErr=strErr & "<link href="../css/normal.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"><br><br><strong>出 错 了 !</strong><br><br></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"><br><br><a href="../default">>> 返回登录页面</a></td></tr>" & vbcrlf
strErr=strErr & "</table>" & vbcrlf
strErr=strErr & "</body></>" & vbcrlf
response.write strErr
end sub
%>
解析:
[/url]看了上面的两条回答,同意二楼的,一楼的没有完全修改过来
正确的文件代码如下:
<%@language=vbscript codepage=936 %>
<!--#include file="conn"-->
<!--#include file="md5"-->
<%
dim sql,rs
dim username,password,CheckCode
username=replace(trim(request("username")),""","")
password=replace(trim(Request("password")),""","")
if UserName="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名不能为空!</li>"
end if
if Password="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>密码不能为空!</li>"
end if
if FoundErr<>True then
password=md5(password)
set rs=server.createobject("adodb.recordset")
sql="select * from admin where password=""&password&"" and username=""&username&"""
rs.open sql,conn,1,3
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
rs("LastLoginIP")=Request.ServerVariables("REMOTE_ADDR")
rs("LastLoginTime")=now()
rs("LoginTimes")=rs("LoginTimes")+1
rs.update
session("admin")=rs("username")
session("purview")=rs("purview")
rs.close
set rs=nothing
call CloseConn()
Response.Redirect "main"
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 & "<><head><title>错误信息</title><meta -equiv="Content-Type" content="text/; charset=gb2312">" & vbcrlf
strErr=strErr & "<link href="../css/normal.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"><br><br><strong>出 错 了 !</strong><br><br></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"><br><br><a href="../default">>> 返回登录页面</a></td></tr>" & vbcrlf
strErr=strErr & "</table>" & vbcrlf
strErr=strErr & "</body></>" & vbcrlf
response.write strErr
end sub
%>