我做了一个登录表单,但重定向不起作用。
$sql = "SELECT * from login where username = '$username' and password = '$password'";
$query = mysqli_query($conn, $sql) or die(mysql_error()) ;
$rows = mysqli_num_rows($query);
if ($rows == 1 ) {
header('Location: home.php');
} else {
echo "Failed";
}
echo "hello";
mysqli_close($conn);
你的问题不完整。 请更详细地更新。
此外,您可以显示文本以更好地识别,而不是标题代码。
如果你的问题是头代码,这基本上是原因:
检查文档开头的空格。
例:
space space space line
<b> <?php
header('Location: panel.php');
?>
</b>
此代码很可能不起作用。
所以改为:
<?php
//First check for redirect..
if( 1 == 1)// or any clause [optional]
{
header('Location: panel.php');
}
?>
<b> <?php echo 5*25; ?>
</b>
另外,为了确保您也可以编写此代码(在header("Location: ...");
之后(。
exit('<meta http-equiv="refresh" content="0;url=link.php" />');
0
是时间。link.php
是目标/链接。