我試圖解決PHP的問題,但我無法找出我的錯誤在哪裏。如果有人能幫助我,請寫一個答案。PHP無法修改標題
PHP發送以下錯誤消息:
[26-Feb-2014 03:00:46 Europe/Berlin] PHP Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/PressIn_21022014/includes/head.php:2) in /Applications/MAMP/htdocs/PressIn_21022014/recap_commande.php on line 41
當我點擊valider_commande
:
<?php
session_start();
if(isset($_SESSION['auth']) && $_SESSION['auth'] == true){
$document = basename(__FILE__);
$titre = "Espace Membre";
include("includes/head.php");
?>
<div class="background col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="container top">
<div class="elements">
<form id="form_top_ten" method="POST" action="recap_commande.php">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="commande_top_ten">
<div class="col-xs-3 col-sm-4 col-md-4 col-lg-3"><h4>Veste</h4></div>
<img src="img/icone_veste.svg" />
<button id="moins_veste" type="button" class="btn-moins btn-circle btn-mini"><i class="glyphicon-minus"></i> </button>
<span class="quantite" id="top_ten_nb_veste">1</span>
<button id="plus_veste" type="button" class="btn-plus btn-circle btn-mini"><i class="glyphicon-plus"></i> </button>
<div class="prix"><span class="prix_pantalon"> 10</span> €</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="commande_top_ten">
<div class="col-xs-3 col-sm-4 col-md-4 col-lg-3"><h4>Pantalon</h4></div>
<img src="img/icone_pant.svg" />
<button id="moins_pantalon" type="button" class="btn-moins btn-circle btn-mini"><i class="glyphicon-minus"></i> </button>
<span class="quantite" id="top_ten_nb_pantalon">1</span>
<button id="plus_pantalon" type="button" class="btn-plus btn-circle btn-mini"><i class="glyphicon-plus"></i> </button>
<div class="prix"><span class="prix_pantalon"> 10</span> €</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="commande_top_ten">
<div class="col-xs-3 col-sm-4 col-md-4 col-lg-3"><h4>Chemise</h4></div>
<img src="img/icone_chemise.svg" />
<button id="moins_chemise" type="button" class="btn-moins btn-circle btn-mini"><i class="glyphicon-minus"></i> </button>
<span class="quantite" id="top_ten_nb_chemise">1</span>
<button id="plus_chemise" type="button" class="btn-plus btn-circle btn-mini"><i class="glyphicon-plus"></i> </button>
<div class="prix"><span class="prix_pantalon"> 10</span> € </div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="commande_top_ten">
<div class="col-xs-3 col-sm-4 col-md-4 col-lg-3"><h4>Robe</h4></div>
<img src="img/icone_robe.svg" />
<button id="moins_robe" type="button" class="btn-moins btn-circle btn-mini"><i class="glyphicon-minus"></i> </button>
<span class="quantite" id="top_ten_nb_robe">1</span>
<button id="plus_robe" type="button" class="btn-plus btn-circle btn-mini"><i class="glyphicon-plus"></i> </button>
<div class="prix"><span class="prix_pantalon"> 10</span> €</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="commande_top_ten">
<div class="col-xs-3 col-sm-4 col-md-4 col-lg-3"><h4>Manteau</h4></div>
<img src="img/icone_manteau.svg" />
<button id="moins_manteau" type="button" class="btn-moins btn-circle btn-mini"><i class="glyphicon-minus"></i> </button>
<span class="quantite" id="top_ten_nb_manteau">1</span>
<button id="plus_manteau" type="button" class="btn-plus btn-circle btn-mini"><i class="glyphicon-plus"></i> </button>
<div class="prix"><span class="prix_pantalon"> 10</span> € </div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="commande_top_ten">
<div class="col-xs-3 col-sm-4 col-md-4 col-lg-3"><h4>Veste</h4></div>
<img src="img/icone_pant.svg" />
<button type="button" class="btn-moins btn-circle btn-mini"><i class="glyphicon-minus"></i> </button>
<span class="quantite" id="top_ten_nb_veste">1</span>
<button type="button" class="btn-plus btn-circle btn-mini"><i class="glyphicon-plus"></i> </button>
<div class="prix"><span class="prix_pantalon"> 10</span> €</div>
</div>
</div>
</div>
<div class="row">
<div class="row col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="commande_top_ten">
<div class="col-xs-3 col-sm-4 col-md-4 col-lg-3"><h4>Pull</h4></div>
<img src="img/icone_pull.svg" />
<button id="moins_pull" type="button" class="btn-moins btn-circle btn-mini"><i class="glyphicon-minus"></i> </button>
<span class="quantite" id="top_ten_nb_pull">1</span>
<button id="plus_pull" type="button" class="btn-plus btn-circle btn-mini"><i class="glyphicon-plus"></i> </button>
<div class="prix"><span class="prix_pantalon"> 10</span> €</div>
</div>
</div>
<div class="row col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="commande_top_ten">
<div class="col-xs-3 col-sm-4 col-md-4 col-lg-3"><h4>Jupe</h4></div>
<img src="img/icone_jupe.svg" />
<button id="moins_jupe" type="button" class="btn-moins btn-circle btn-mini"><i class="glyphicon-minus"></i> </button>
<span class="quantite" id="top_ten_nb_jupe">1</span>
<button id="plus_jupe" type="button" class="btn-plus btn-circle btn-mini"><i class="glyphicon-plus"></i> </button>
<div class="prix"><span class="prix_pantalon"> 10</span> €</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="commande_top_ten">
<div class="col-xs-3 col-sm-4 col-md-4 col-lg-3"><h4>Draps</h4></div>
<img src="img/icone_drap.svg" />
<button type="moins_drap" class="btn-moins btn-circle btn-mini"><i class="glyphicon-minus"></i> </button>
<span class="quantite" id="top_ten_nb_drap">1</span>
<button type="plus_drap" class="btn-plus btn-circle btn-mini"><i class="glyphicon-plus"></i> </button>
<div class="prix"><span class="prix_drap"> 10</span> €</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="commande_top_ten">
<div class="col-xs-3 col-sm-4 col-md-4 col-lg-3"><h4>Chemise</h4></div>
<img src="img/icone_chemisepliee.svg" />
<button type="moins_drap" class="btn-moins btn-circle btn-mini"><i class="glyphicon-minus"></i> </button>
<span class="quantite" id="top_ten_nb_drap">1</span>
<button type="plus_drap" class="btn-plus btn-circle btn-mini"><i class="glyphicon-plus"></i> </button>
<div class="prix"><span class="prix_pantalon"> 10</span> €</div>
</div>
</div>
</div>
<button type ="submit" class="btn_valider btn btn-danger col-xs-9 col-sm-6 col-md-6 col-lg-4" name="valider_commande" value="valider_commande"><i class="glyphicon glyphicon-shopping-cart"></i>Valider commande (' .$prix_total. ' euros)</button>
</form>
</div>
</div>
<?php
if (!empty($_SESSION['form_top_ten'])){
$nb_articles = sizeof($_SESSION['commande_top_ten']);
$prix_total = 0;
for ($i=0;$i<$nb_articles;$i++){
$prix_total += $_SESSION['commande_top_ten'][$i]['prix'];
}
}
?>
</div>
<?php
}
else{
header('Location:auth_form.php');
}
?>
這是head.php線2:
<head>
**<title>E-Pressing - <?php echo $titre; ?></title>**
<link href="css/bootstrap.css" rel="stylesheet">
<meta charset="UTF-8">
<link href="css/business-frontpage.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Poiret+One' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic' rel='stylesheet' type='text/css'>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
</head>
感謝您的幫助!
感謝您的回答,但我已經知道了,我已經檢查,但我沒有找到錯誤! –
嘗試反轉if。 'if(!isset($ _ SESSION ['auth'])&& $ _SESSION ['auth']!= true){'所以,改變標題。我在這裏僞造,它的工作原理。 –