可能重复:
PHP 已发送的标头
这是我当前的脚本。页面不会像我希望的那样重定向,而是刷新到当前页面。该页面曾经可以工作,但最近无缘无故停止工作。我在 PHP 5.3
<?php
$page = "Edit Topic";
require('top.php');
$var = safe($_GET['id']);
$q = mysql_query("SELECT * FROM `topics` WHERE `id`='".$var."'");
$r = mysql_fetch_array($q);
$c = mysql_num_rows($q);
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$_SESSION['id']."'"));
if($c==0) {
echo "<p>This topic does not exist.</p>";
} elseif($_SESSION['name'] != $r['poster'] && $user['rank'] == "Member") {
echo "<p>This is not your topic.</p>";
} else {
if(isset($_POST['enter'])) {
$title = safe($_POST['title']);
$post = safe($_POST['post']);
if($post=='' || $title=='') {
$message = "You have to write something in your title and post.";
} else {
mysql_query("UPDATE `topics` SET `text`='".$post."' WHERE `id`='".$r['id']."'");
mysql_query("UPDATE `topics` SET `title`='".$title."' WHERE `id`='".$r['id']."'");
header("Location: http://www.domain.com/view-post/".$r['id']."");
}
}
}
?>