2016-07-24 67 views
-2

我想在我的真实服务器页面中使用header(),但它不起作用。如果我在本地主机上的Xammp中尝试它,它工作正常。php头与本地主机正常工作,但不与真正的服务器一起工作

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; 
     } 
    } 

那么你能帮我吗?

+0

一旦你检查错误,你会发现为什么 –

+0

好吧,你能给我任何方式,让我调试错误 – abzoghbi

+0

***你真的不应该使用[MD5密码散列](http://security.stackexchange.com/questions/19906/is- md5认为不安全)***,你真的应该使用PHP的[内置函数](http://jayblanchard.net/proper_password_hashing_with_PHP.html)来处理密码安全性。在散列之前,请确保你[不要越过密码](http://stackoverflow.com/q/36628418/1011527)或使用其他任何清理机制。这样做*更改密码并导致不必要的附加编码。 –

回答

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> 
相关问题