Le code pour effacer le panier :
<?
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta http-equiv="imagetoolbar" content="no" />
<link rel="stylesheet" type="text/css" href="artotheque.css" />
<style type="text/css">
<!--
body {
background-image: none;
margin: 20px;
}
td {
background-color: #EFDABD;
padding: 2px;
vertical-align: top;
}
-->
</style>
</head>
<body>
<h1>Votre panier</h1>
<?
if(isset($_GET["del_panier"]))
{
$nombre_oeuvres = count($_SESSION["tableau_panier"]);
$oeuvre_a_supprimer = $_GET["del_panier"];
$occurence = 0;
while($occurence < $nombre_oeuvres)
{
if($_SESSION["tableau_panier"][$occurence]==$oeuvre_a_supprimer)
{
$_SESSION["tableau_panier"][$occurence]="effacé";
}
$occurence++;
}
}
?>
<p style="font-weight: bold;">
Cette oeuvre est effacée du panier.
</p>
<?
sleep(2);
header("Location: panier.php");
?>
</body>
</html>
.. et l'erreur :
Warning: Cannot modify header information - headers already sent by output started at home ...
Après recherche il apparait qu'il ne doit pas y avoir d'html avant le header et je pensais avoir trouvé la solution avec ceci :
<?php
ob_start();
?>
<?
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta http-equiv="imagetoolbar" content="no" />
<link rel="stylesheet" type="text/css" href="artotheque.css" />
<style type="text/css">
<!--
body {
background-image: none;
margin: 20px;
}
td {
background-color: #EFDABD;
padding: 2px;
vertical-align: top;
}
-->
</style>
</head>
<body>
<h1>Votre panier</h1>
<?
if(isset($_GET["del_panier"]))
{
$nombre_oeuvres = count($_SESSION["tableau_panier"]);
$oeuvre_a_supprimer = $_GET["del_panier"];
$occurence = 0;
while($occurence < $nombre_oeuvres)
{
if($_SESSION["tableau_panier"][$occurence]==$oeuvre_a_supprimer)
{
$_SESSION["tableau_panier"][$occurence]="effacé";
}
$occurence++;
}
}
?>
<p style="font-weight: bold;">
Cette oeuvre est effacée du panier.
</p>
<?
sleep(2);
?>
<?php
header("Location: panier.php");
ob_flush();
?>
</body>
</html>
L'erreur est disparue, mais pas de petit message, ce n'est pas super génant, mais je me demande si ce n'est pas ca qui entraine une erreur dans le calcul des œuvre(s) restant dans le panier. Il y a peut etre une solution javascript ? j'en ai tenté une mais sans succès, la temporisation de l'affichage n'est pas respectée, quel que soit le temps imposé.
Merci de vos conseils.




Haut










