0

我的标头在我的本地主机上工作,但不能在线工作。

<?php
require_once 'func/func.php';


if(isset($_POST['sub'])){

$user = trim(mysqli_real_escape_string($dbc,$_POST['username']));
$pass = mysqli_real_escape_string($dbc,$_POST['pass']);
$sql = "select * from register where matric = '$user' and passw ='$pass'";
$result = mysqli_query($dbc,$sql) or die(mysqli_error($dbc));

$num = mysqli_num_rows($result) or die(mysqli_error($dbc));


if($num == 1){


$_SESSION['user_id'] = $row['user_id'];
$_SESSION['name'] = $row['fname'].' '.$row['lname'];
$_SESSION['trader'] = $row['trader'];
$_SESSION['pic'] = $row['passport'];
$_SESSION['username'] = $row['username'];
error_reporting(E_ALL | E_WARNING | E_NOTICE);
       ini_set('display_errors', TRUE);


         flush();
       header("Location: home/home.php");
                    die('should have redirected by now');


   echo $pass;
     }else{
  echo "Invalid User Name or Password";

   }
}


  ?>
 <html><head>

 </head>
 <body>
  <form action="" method="post">
<table width="409" border="0" align="center" cellpadding="4" cellspacing="4">
 <tr>
<td width="166">User Name</td>
<td width="215">

    <input type="text" name="username" id="text1">

</tr>
 <tr>
<td>Password</td>
<td><p>

    <input type="password" name="pass" id="password1">

</tr>
  <tr>
<td colspan="2" align="center"><input name="sub" type="submit" value="Login" /></td>
</tr>
   </table>
   <? if(isset($msg)) echo $msg; ?> </form>

 </body></html>

func 文件包含它在 localhost 上工作的会话和 mysqli 连接文件。上面有所有错误并没有显示错误。它的输出应该已经重定向了。请帮帮我

4

2 回答 2

0

您的重定向有效。问题是 URL 不正确。

试试这样:

header("Location: http://site.com/home/home.php");
于 2012-10-07T11:55:57.083 回答
0

试试这个方法:

header("Location: ./home/home.php"); 
于 2012-10-07T11:57:06.100 回答