我的标题正在我的本地主机上工作,但没有在线工作。
<?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连接文件。 所有错误都没有出现错误。现在输出已经重定向了。请帮帮我
答案 0 :(得分:0)
您的重定向有效。 问题是URL不正确。
试试这样:
header("Location: http://site.com/home/home.php");
答案 1 :(得分:0)
尝试这种方式:
header("Location: ./home/home.php");