帮忙找找这个登录代码在哪出错?
出错现象:登录后在loginchk.asp页面出错,无法进入首页。不知道是哪出了问题。
下面附上conn.asp,index.asp,loginchk.asp三个文件的代码。
'--------------------conn.asp
<%
dim conn,mydb,startime,db,rs,UserAgent
db="adminuser/dada/#9idns_Data.mdb"
Set Conn = Server.CreateObject("ADODB.Connection")
mydb="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
Conn.Open Mydb
%>
<%
UserAgent = Trim(Lcase(Request.Servervariables("HTTP_USER_AGENT")))
If InStr(UserAgent,"teleport") > 0 or InStr(UserAgent,"webzip") > 0 or InStr(UserAgent,"flashget")>0 or InStr(UserAgent,"offline")>0 Then
Response.Write "请不要采用teleport/Webzip/Flashget/Offline等工具来浏览网站!"
Response.End
End If
ThisFilePath=Request.ServerVariables("PATH_INFO")
ThisFileName=lcase(Mid(ThisFilePath,InstrRev(ThisFilePath,"/")+1)) '获取本文件的名字
PPst_Path="PPst_UpLoadFile" '前后都不能带/
PPst_Path0=Replace(ThisFilePath,Mid(ThisFilePath,InstrRev(ThisFilePath,"/")+1),"")&PPst_Path '原始大小写保持不变
PPst_Path1=Replace(lcase(ThisFilePath),ThisFileName,"")&PPst_Path '全部小写
Function PPst_Save(Content)
PPst_Save=Replace(Replace(Content,PPst_Path0,PPst_Path1),PPst_Path1,PPst_Path)
End Function
Function PPst_Get(Content)
PPst_Get=Replace(Content,PPst_Path,PPst_Path1)
End Function
Function HtmlCode(HtmlStiring) '定义一个简单的HTML代码替换函数
HtmlStiring=Replace(HtmlStiring,"<","<")
HtmlStiring=Replace(HtmlStiring,">",">")
HtmlStiring=Replace(HtmlStiring,VBCrlf,"<br>")
HtmlStiring=Replace(HtmlStiring," "," ")
HtmlCode=HtmlStiring
End Function
Function TitleLeft(str,strlen) '函数,将汉字计算为两个字符
Dim l,t,c, i
l=len(str)
t=0
For i=1 to l
c=Abs(Asc(Mid(str,i,1)))
If c>255 then
t=t+2
Else
t=t+1
End if
If t>=strlen then
TitleLeft=left(str,i)&".."
Exit for
Else
TitleLeft=str&""
End If
Next
End Function
%>
'----------------------------------------------index.asp
<!--#include file="conn.asp"-->
<table width="170" border="0" cellpadding="0" cellspacing="0">
<form id="form1" name="form1" method="post" action="mumber/loginchk.asp" onsubmit="return xxg()">
<tr>
<td width="61" height="25" align="center" >用户名:</td>
<td width="109" align="left"><input name="username" type="text" class="top_input" id="username" style="width:100px;" /></td>
</tr>
<tr>
<td height="25" align="center">密 码:</td>
<td align="left"><input name="password" type="password" class="top_input" id="password" style="width:100px;" /></td>
</tr>
<tr>
<td height="25" align="center" >验证码:</td>
<td align="left"><input name="Verifycode" type="text" id="Verifycode" style="width:40px;height:14px;border:1px solid #cccccc" />
<b><%=s%></b>
<input name="slogin" type="hidden" id="slogin" value="<%=s%>" size="12" maxlength="20" /></td>
</tr>
<tr>
<td height="25" align="center"> </td>
<td align="left"><input type="image" name="imageField" src="images/user.gif" style="height:18px;" /></td>
</tr>
<tr>
<td height="40" colspan="2" align="center" >如果您想加入本站会员<br />
请点击<a href="reguser.asp"><font color="#FF0000">会员注册</font></a></td>
</tr>
</form>
</table>
'----------------------- loginchk.asp
<!--#include file="../conn.asp" -->
<!--#include file="../include/md5.asp" -->
<%
s=Trim(Request.Form("slogin"))
s2=Request.Form("Verifycode")
If s2<>s Then
Response.Write("<script language=javascript>alert('请输入正确的认证码!');history.back()</script>")
Response.End
end if
'====================================
LoginName=replace(trim(request.form("username")),"'","''")
LoginPassword=Md5(replace(trim(request.form("password")),"'","''"))
'====================检测姓名中是否含有非法字符开始
if instr(username,"%") or instr(username,"#") or instr(username,"?") or instr(username,"|") then
response.write "<script language=javascript>alert('您的姓名含有非法字符!');history.back()</script>"
response.end
end if
'====================检测姓名中是否含有非法字符end
if instr(password,"%") or instr(password,"#") or instr(password,"?") or instr(password,"|") then
response.write "<script language=javascript>alert('您的密码含有非法字符!');history.back()</script>"
response.end
end if
'====================检测密码中是否含有非法字符
set rs=server.createobject("adodb.recordset")
rs.open "select * from [user] where username='"&LoginName&"'",conn,1,3
if rs.eof then
response.write "<script language=javascript> alert('用户名称不正确,请重新输入。');history.back();</script>"
response.end
else
username=rs("username")
Password=rs("Password")
end if
if LoginPassword<>Password then
response.write "<script language=javascript> alert('密码不正确,请重新输入。');history.back();</script>"
response.end
end if
if LoginName=username and LoginPassword=Password then
rs("logintime")=now()
rs("loingIP")=Request.ServerVariables("Remote_Addr")
session("uusername")=rs("username")
session("xingming")=rs("xingming")
session("uuserid")=rs("id")
Response.Cookies("uusername") = rs("username")
Response.Cookies("uusername").Expires=date()+365
rs.update
session.timeout=30
rs.close
set rs=nothing
'==================================
response.redirect "index.asp"
response.end
end if
conn.close
set conn=nothing
%>