我正在开发一个 PHP 项目,我试图使用标头(位置:something.php)从一个页面重定向到另一个页面。它在本地机器上工作正常,但是当上传到服务器时,出现以下错误:
Warning: Cannot modify header information - headers already sent by (output started at /homepages/4/d404449574/htdocs/yellowandred_in/newTest/editHome.php:15) in /homepages/4/d404449574/htdocs/yellowandred_in/newTest/editHome.php on line 43
我已经尝试过include
, include_once
,但它给出了其他错误,例如require
:require_once
Cannot redeclare logged_in() (previously declared in C:\wamp\www\ynrNewVersion-1\editHome.php:3) in C:\wamp\www\ynrNewVersion-1\adminIndex.php on line 5
我的代码
<?php
session_start();
function logged_in() {
return isset($_SESSION['username']);
}
function confirm_logged_in() {
if (!logged_in()) {
include "error404.php";
exit;
}
}
confirm_logged_in();
require_once("connection.php");
$query="select * from home";
$homeInfo = mysql_query($query, $connection);
$result = mysql_fetch_array($homeInfo);
$content = $result['content'];
$rssFeeds = $result['rssFeeds'];
$message = "";
if(isset($_POST['submit'])){
$content = $_POST['content'];
$rssFeeds = $_POST['rssFeeds'];
if($content == "" || $rssFeeds == ""){
$message = "Please enter into all the fields";
} else {
$query = "UPDATE home SET content='$content',rssFeeds='$rssFeeds' WHERE id=1 LIMIT 1";
$result = mysql_query($query,$connection);
if(!$result){
echo "error".mysql_error();
}
if ($result == 1) {
header("Location:adminIndex.php");
} else {
$message = "Error Occurred";
}
}
}
if(isset($_POST['cancel'])){
header("Location:adminIndex.php");
}
?>