为什么 运行后就直接执行了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"> <div align="center"> <input type="submit" name="Submit" onClick="return check();" value="登录"> <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>