跳转到另一个页面:
echo "<script>top.location.href='xxxx.php';</script>";

解决方案 »

  1.   

    谢谢你,我是这样写的
    <?php
    $query="SELECT * from zhengshu where xm='$name' and zsbh='$number' and csrq='$time' and xb='$sex'";
    $mydb->query($query);
    $mydb->next_record();
    //等待帮助的地方
    $name2=$mydb->f(xm);if($name2=''){
    echo"<script>top.location.href='xxxx.php';</script>";
    }
    ?>
    数据库没有记录,怎么还是没有跳转呢?
      

  2.   

    我是这样想的$name2=$mydb->f(xm);我想$name2是取的字段xm,如果没有获取值,就执行if($name2='')echo"<script>top.location.href='xxxx.php';</script>";怎么还是没有反映呢?
      

  3.   

    你先看看执行你这段JS没有先,查看源代码
    if($name2=''){
    echo "is NULL";
    //echo"<script>top.location.href='xxxx.php';</script>";
    }
    else {
    echo "isn't NULL";
    }
      

  4.   

    试试,更方便
    echo '<meta http-equiv="refresh" content="0;URL=xx.htm">';
      

  5.   

    楼上说的都可以。还有一种:header("location:xxxxx.php");//但要保证在执行此程序之前,没有任何信息输入浏览器
      

  6.   

    echo "<script>top.location.href='xxxx.php';</script>";
    echo '<meta http-equiv="refresh" content="0;URL=xx.htm">';
    header("location:xxxxx.php");//但要保证在执行此程序之前,没有任何信息输入浏览器
      

  7.   

    -> if($name2='')
    语法错误 写也应该是if($name2=='')
    用这个吧: if(empty($name2))
      

  8.   

    给你一个函数吧:
    function login($username,$password){
    global $dbhost,$dbuser,$dbpasswd,$dbname,$down_user_table,$cookie_name;$sql = "SELECT * FROM $down_user_table WHERE username='$username'";
    $result = mysql_db_query($dbname, $sql);
    $objresult = mysql_fetch_object($result);
    $user_password = $objresult->password;if ($username=="" || $password==""):
    echo "用户名或密码不能为空";
    echo "<br><a href=javascript:history.back(1)>点击这里返回</a>";
    exit;
    endif;if ($user_password == ""):
    echo "用户名错误";
    echo "<br><a href=javascript:history.back(1)>点击这里返回</a>";
    exit;
    endif;if ($password != $user_password):
    echo "密码错误";
    echo "<br><a href=javascript:history.back(1)>点击这里返回</a>";
    exit;
    endif;setcookie ($cookie_name."[1]",$username,time()+(1*24*3600));
    setcookie ($cookie_name."[2]",$password,time()+(1*24*3600));echo "登录成功!";
    //echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL=list.php'>";exit;} // end login
      

  9.   

    基本上就是那个两个:
     header("location:yoururl");
     or
     <Script lauguage=javascript>window.location.href=url</script>