可能重复:
PHP 已发送的标头
错误:
Warning: Cannot modify header information - headers already sent by (output started at functions.php:37) in functions.php on line 207
添加.php
<?php include('functions.php'); ?>
<?php global_header("Add"); ?>
<?php page_navigation(); ?>
<?php
// If no form has been submitted, present form
if (empty($_POST))
{
add_form();
}
// if a form has been submitted
else
{
// if form_validity() == 1, proceed to connect
if (form_validity() == 1)
{
// connect to mysql + database
connect();
// get values from form, insert into database
$saleItemCheck = isset($_POST['saleItem'])?"y":"n";
$discItemCheck = isset($_POST['discountedItem'])?"y":"n";
$sql=("INSERT INTO inventory (name, manufac, model, descrip, onhand, reorder, cost, price, sale, discont, deleted)
VALUES ('$_POST[itemName]', '$_POST[manufacturer]', '$_POST[model]', '$_POST[description]', '$_POST[numberOnHand]',
'$_POST[reorderLevel]', '$_POST[cost]','$_POST[sellingPrice]',
'$saleItemCheck', '$discItemCheck', 'n')");
// if the query doesn't work, display error message
if (!(mysql_query($sql))) { die ("could not query: " . mysql_error()); }
add_form();
redirect("view.php");
}
else
{
// if form is not valid (form_validity returns 0), display error messages
add_form();
}
}
?>
<?php page_footer(); ?>
我的重定向功能
<?php
function redirect($page)
{
header('Location:'.$page); <------------------------------------ line 207
}?>
头功能
<?php
function global_header($page_title)
{
$content = '<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>DIMAS OLYMPIC WEIGHTLIFTING EQUIPMENT - ' . $page_title . '</title>
<meta name="description" content="BTI320 Assignment 1">
<meta name="author" content="Marcel Olszewski - 078-681-103">
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="container">
<div><img src="logo.png" id="logo" alt="I (Marcel Olszewski) created this in photoshop" /></div>';
echo $content; <------------------- LINE 37
}
?>
以前有效,现在无效,不太清楚为什么。