标题:为什么 运行后就直接执行了response.write "<script>alert('登录失败!!!'); ...
取消只看楼主
kevinxu0638
Rank: 2
来 自:江苏
等 级:论坛游民
帖 子:147
专家分:62
注 册:2009-10-19
结帖率:100%
 问题点数:0 回复次数:1 
为什么 运行后就直接执行了response.write "<script>alert('登录失败!!!');history.back();
程序代码:
<!--#Include file="conn.asp"-->
<%
Dim Sql,rs,username,password
username=request.form("username")

 password=request.form("password")
set rs=server.createobject("adodb.recordset")
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网上书城</title>
<link href="images/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
#Layer1 {
    width:778px;
     height:335px;
     position:absolute;
     left:49%;
     top:39%;
     margin:-205px 0 0 -380px;
       }
#Layer2 {
    position:absolute;
    width:359px;
    height:89px;
    z-index:2;
    left: 389px;
    top: 88px;
}
-->
</style>
</head>
<body>
<div id="Layer1">
  <div align="left"><img src="images/login_pic.png" width="378" height="265" align="bottom" /><img src="images/login_right.jpg" width="400" height="340" border="0" align="absmiddle" usemap="#Map" />
<map name="Map">
  <area shape="rect" coords="201,38,281,71" href="tiao.asp">
<area shape="rect" coords="143,234,218,264" href="adminloginform.asp">
</map>
    <div id="Layer2">
      <form  name="loginfo" method="POST" action="login.asp">
  <table width="237" border="0" align="center" bgcolor="#EDF6FF">
        <tr>
      <td width="64">用户名:</td>
      <td width="120"><input type="text" name="username"></td>
    </tr>
    <tr>
      <td>密码:</td>
      <td><input type="password" name="password"></td>
    </tr>
    <tr>
          <td colspan="2">
            &nbsp;&nbsp;&nbsp;
            <div align="center">
              <input type="submit" name="Submit" onClick="return check();" value="登录">
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="reset" name="Submit2" value="重置">
                </p>
              </div></td></tr>
  </table>
</form>
    </div>
  </div>
</div>
</body>
</html>
<%
sql="select username,password from admin where username='"&username&"'"

 rs.open sql,conn,1,1
if rs.eof then
  response.write "<script>alert('登录失败!!!');history.back();</script>"
  response.end
  else
    if rs("password")<>password then
      response.write "<script>alert('登录失败!!');history.back();</script>"
      response.end    
     end if     
response.write"<script>alert('登录成功');location.href='" & request.ServerVariables("HTTP_REFERER")& "';</script>"
  end if
%>
<script language="JavaScript">
<!--
function check()
{
    if(checkspace(document.loginfo.username.value)) {
    document.loginfo.username.focus();
    alert("用户名不能为空!");
    return false;
  }
   if(checkspace(document.loginfo.password.value)) {
    document.loginfo.password.focus();
    alert("密码不能为空!");
    return false;
  }
}
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
//-->
</script>
搜索更多相关主题的帖子: password 
2012-02-28 10:51
kevinxu0638
Rank: 2
来 自:江苏
等 级:论坛游民
帖 子:147
专家分:62
注 册:2009-10-19
得分:0 
回复 楼主 kevinxu0638
我知道为什么出现这样了 是运行是username为空  但是加了if username<>"" 后还是没打到预期效果 唉 再找找

javascript、asp学习研究中 希望高手多多指教
2012-02-28 11:11



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-361759-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.091747 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved