if(isset($account)&&isset($pass))  //判断用户是否输入完整
{
    $query="select password,user_id from userinfo where username='$account'";
    
    if(!$result=mysql_query($query,$connect))
    {
        header("Location:index.php"); //数据库错误,跳转
     }

    if(mysql_num_rows($result))     //查找到用户
    {
         $ps=mysql_fetch_row($result);
if(!strcmp($pass,$ps[0]))                  //判断密码
{
             //通过验证
          }
 else
 {  
               echo "self.location='index.php";  //验证失败
  }    
  
    }
  else
    {
        ///无该用户
    }

}