$conn=mysql_connect('localhost','root','root'); mysql_select_db('testdb',$conn); mysql_query('set name gbk',$conn); if (!empty($_REQUEST['n'])||!empty($_REQUEST['p'])) { $username=$_REQUEST['n']; $password=$_REQUEST['p']; $arr=mysql_query("select * from admin where username='$username'and password='$password',$conn"); if ($arr) { echo "<script type=text/javascript>alert('登录成功');window.location.href='login-1.php';</script>"; } else { echo "<script type=text/javascript>alert('用户名或密码错误');window.location.href='login-second.html';</script>"; } }