php标头适用于localhost,但不适用于真正的服务器

时间:2016-07-24 22:45:42

标签: php apache header

我正在尝试在真实服务器上的页面中使用header(),但它不起作用。如果我在localhost上的Xammp中尝试它,它可以正常工作。

if(empty($_POST)===false){
        include_once("db.php");
        $username = $_POST['user'];
        $pwd = $_POST['pwd'];

        $rs = mysqli_query($con,"select *from admin_acc where username = '".$username."'");
        $num_rows = mysqli_num_rows($rs);

        if($num_rows > 0){
        while($rows = mysqli_fetch_assoc($rs))
        {
            $db_username = $rows['username'];
        }

        if($username == $db_username && md5($pwd) == $db_password){
            $_SESSION['username'] = $db_username;

            //Header to Home Page
            header('Location: customers.php');

        }else{
            $wrng_pwd = "Wrong Password!";  
            $msg_type = 1;
        }
        }else{
            $user_nt = "User name not exsit!!"; 
            $msg_type = 2;
        }
    }

你能帮我吗?

1 个答案:

答案 0 :(得分:0)

我终于找到解决方案是使用java脚本比php标头更好

例如:

<script type="text/javascript">
window.location.href = 'http://www.google.com';
</script> 

<script type="text/javascript">
window.location.href = 'page2.php/';
</script>