<?php
 include "../conn.php";
?>
<?php
ob_start();
$user_id=$_POST['userid'];
$passwd=$_POST['password'];
$exe=$user_id;
//echo $user_id;
 $sql="select * from tb_user where user_id='$userid' and password='$passwd'";
 $flag = mysql_query($sql);
$result = mysql_fetch_array($flag);
$user_type = $result["user_type"];
 if($result!=false)
 {
  echo "<script> alert('".$user_id."登陆成功'); </script>";
}
  else{
  echo "<script> alert('用户名或密码错误'); </script>";
  echo '<script>window.location="../main.php";</script>';
          }
?>
<html>
<head>
<script>
function showpage(obj,user_id,user_type)
{
window.location="./top.php?userid="+user_id+"&&user_type="+user_type;
}
</script>
</head>
<body>
<a href="javascript:showpage(this,<?php echo $user_id; ?>);" class="navText">登记</a>
</body>
</html>不能跳转,不知道是什么问题。是一网页错误

解决方案 »

  1.   

    你showpage函数传进去的值只有前两个,没第三个值user_type,但你js函数里又用到了user_type,怎么可能不错?
      

  2.   

    楼上正解.
    应改成:
    <body> 
    <a href="javascript:showpage(this, <?php echo $user_id; ?>,<?php echo $user_type; ?>);" class="navText">登记 </a> 
    </body>
      

  3.   

    window.location=改为:window.location.href=最好能把错误帖出来
      

  4.   

    $sql="select * from tb_user where user_id='$userid' and password='$passwd'"; 改成这样试一下看看
    $sql="select * from tb_user where user_id='".$userid."' and password='".$passwd."'";