1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| <?Php
session_start();
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Action sur le panier</title>
</head>
<body>
<?Php
// Declaring session array
//array_push($_SESSION['panier'],'apple','mango','banana'); */// Items added to cart
switch($_POST['action']){
case "ajouter":
$nom=$_POST["nom"];
$ref=$_POST["ref"];
$qte=$_POST['qte'];
$prix=$_POST["prix"];
$cat=$_POST["cat"];
//echo $nom." ".$ref."la qte ".$qte." ".$prix." ".$cat;
if (isset($_SESSION['panier'][$ref]))
{
$_SESSION['panier'][$ref]['qte'] += $qte;
}else {
$_SESSION['panier'][$ref] = array('nom'=>$nom, 'qte'=>$qte,'prix'=>$prix,'cat'=> $cat);
}
header("Location:testadd.php");
break;
case "modifier":
if(!empty($_POST['cat'])){
$cat=$_POST['cat']; echo "je suis ici";
header("Location:produit.php?cat=".$cat."");
}
break;
break;
case "supprimer":
if(!empty($_POST['ref'])){
$ref=$_POST['ref'];
unset($_SESSION['panier'][$ref]);
header("Location:panier.php");
}
break;
case "vider le panier":
unset($_SESSION['panier']);
echo "votre panier est vide";
default:
header("Location:panier.php");
}
?>
</body>
</html> |