注册 登录
编程论坛 ASP技术论坛

麻烦高手看下这段代码到底哪里错了!!

fujian567 发布于 2010-05-18 23:54, 506 次点击
<!--#include file="../config/conn.asp"-->
<%
dim rs,sql
sql="select admin,password from tbl_admin where admin='"&request.form("adminname")&"' and password='"&(request.form("adminpsw"))&"'"
rs.open sql,conn,1,1
  if rs.eof  or rs.bof  then
  response.write "<script language=JavaScript>" & chr(13) & "alert('用户名或密码错!');"&" </script>"
     rs.close
     set rs=nothing
     set conn=nothing
     response.end()
  else
   response.write "<script language=JavaScript>" & chr(13) & "alert('登陆成功!');"&"window.location.href = 'admin.asp'"&" </script>"
     rs.close
     set rs=nothing
     set conn=nothing
  end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>网站后台管理</title>

<script LANGUAGE="javascript">
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
function check()
{
  if(checkspace(document.admininfo.adminname.value)) {
    document.admininfo.adminname.focus();
    alert("管理员不能为空!");
    return false;
  }
  
  if(checkspace(document.admininfo.adminpsw.value)) {
    document.admininfo.adminpsw.focus();
    alert("密码不能为空!");
    return false;
  }
    document.admininfo.submit();
  }
</script>
</head>
<body>
<table width="681" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top:120px">
  <tr>
    <td width="353" height="259" align="center" valign="bottom" background="Images/login_1.gif"><table width="90%" border="0" cellspacing="3" cellpadding="0">
      
    </table></td>
    <td width="195" background="Images/login_2.gif"><table width="190" height="106" border="0" align="center" cellpadding="2" cellspacing="0">
      <FORM  name="admininfo" action="login.asp" method=post onSubmit="return check()">
            <tr>
              <td height="50" colspan="2" align="left">&nbsp;</td>
            </tr>
            <tr>
              <td width="60" height="30" align="left">登陆名称</td>
              <td><input name="adminname" type="TEXT" style="background:url(Images/login_6.gif) repeat-x; border:solid 1px #27B3FE; height:20px; background-color:#FFFFFF" id="UserName"size="14"></td>
            </tr>
            <tr>
              <td height="30" align="left">登陆密码</td>
              <td><input name="adminpsw"  type=password style="background:url(Images/login_6.gif) repeat-x; border:solid 1px #27B3FE; height:20px; background-color:#FFFFFF" id="Password" size="16"></td>
            </tr>
            <tr>
              <td height="40" colspan="2" align="center"><img src="Images/tip.gif" width="16" height="16"> 请勿非法登陆!</td>
          <tr>
              <td colspan="2" align="center"><input type="submit" name="submit" style="background:url(Images/login_5.gif) no-repeat" value=" 登  陆 ">
              <input type="reset" name="Submit" style="background:url(Images/login_5.gif) no-repeat" value=" 取  消 "></td>
            <tr>
              <td height="5" colspan="2"></td>
        </form>
    </table></td>
    <td width="133" background="Images/login_3.gif">&nbsp;</td>
  </tr>
  <tr>
    <td height="161" colspan="3" background="Images/login_4.gif"></td>
  </tr>
</table>
</body>
</html>
这是显示错误
Microsoft VBScript ԋАʱ?펳 '800a01a8'

ȱə?ԏ󺠧'

\admin\login.asp, line 5

3 回复
#2
gupiao1752010-05-19 10:35
你的编码没改好吧,错误都变成了乱码!设置一下,顶端加这个:
<html>
<head>
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=gb2312">即可!

800a01a8错误应该对应的错误提示就是:缺少对象!
检查../config/conn.asp文件里是否已经设置了rs对象,比如set rs=server.createobject("adodb.recordset"),另注意检测提示行附近的变量名称是否正确!
还有如下SQL语句,感觉这么写有点不符合常规:建议更改如下:
dim name,pass
name=request.form("adminname")
pass=request.form("adminpsw")
sql="select admin,password from tbl_admin where admin='"&name&"' and password='"&pass&"'"

#3
fujian5672010-05-19 12:53
按照你的方法改了,可是还是出现了
Microsoft VBScript 运行时错误 '800a01a8'

缺少对象: ''

\admin\login.asp, line 8


这样的错误
我在定义变量的时候多加了
dim name,pass,rs,sql
如果不加的话
就出现了
Microsoft VBScript 运行时错误 '800a01a8'

缺少对象: 'rs'

\admin\login.asp, line 8

另外conn.asp 这个文件只是定义了打开数据库,在没有别的了
如下
dim conn,dbpath
set conn=server.CreateObject("adodb.connection")
dbpath="/db/"
conn.open "DRIVER=Driver do Microsoft Access (*.mdb);DBQ="&Server.MapPath(dbpath & "hegu.mdb")
session.Timeout=15


[ 本帖最后由 fujian567 于 2010-5-19 12:55 编辑 ]
#4
fujian5672010-05-19 12:57
谢谢,已经改好了
,知道哪里出错了
1