header() 方法不起作用
header() method doesn't work
我想让它重定向,但它没有返回。我知道 header() 方法不应该调用任何输出结果,但我不知道我在哪里写了 returns 输出的方法。
这是我的来源:
<?php include 'database.php';
$message = mysqli_real_escape_string($con, $_POST['message']);
date_default_timezone_set('Iran');
$time = date('h:i:s a',time());
if(!isset($message) || $message == ''){
$error = "Fill the textbox";
header("Location: harf.php?error=".urlencode($error));//changed
exit();
} else {
$query = "INSERT INTO main (user,message,time) VALUES('ROBOT','$message','$time')";
if (!mysqli_query($con,$query)) {
die('Error: '.mysqli_error($con));//changed
} else {
header("Location: harf.php");
exit();
}
}?>
谢谢
你这里有拼写错误
header("Locaton: harf.php?error=".urlencode($error));
以此改变
header("Location: harf.php?error=".urlencode($error));
我想让它重定向,但它没有返回。我知道 header() 方法不应该调用任何输出结果,但我不知道我在哪里写了 returns 输出的方法。 这是我的来源:
<?php include 'database.php';
$message = mysqli_real_escape_string($con, $_POST['message']);
date_default_timezone_set('Iran');
$time = date('h:i:s a',time());
if(!isset($message) || $message == ''){
$error = "Fill the textbox";
header("Location: harf.php?error=".urlencode($error));//changed
exit();
} else {
$query = "INSERT INTO main (user,message,time) VALUES('ROBOT','$message','$time')";
if (!mysqli_query($con,$query)) {
die('Error: '.mysqli_error($con));//changed
} else {
header("Location: harf.php");
exit();
}
}?>
谢谢
你这里有拼写错误
header("Locaton: harf.php?error=".urlencode($error));
以此改变
header("Location: harf.php?error=".urlencode($error));