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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| <?php
session_start();
include_once("fonctions-panier.php");
if (isset($_GET['action']))
{
$erreur=false;
if(in_array( $_GET['action'],array('ajout', 'suppression', 'refresh')))
$action = $_GET['action'];
else
$erreur=true;
$l = preg_replace('#\v#', '', $_GET['l']);
$q = intval($_GET['q']);
$p = floatval($_GET['p']);
}
elseif(isset($_POST['action']))
{
unset($_GET);
$erreur=false;
if(in_array($_POST['action'],array('ajout', 'suppression', 'refresh')))
$action=$_POST['action'];
else
$erreur=true;
$l = preg_replace('#\v#', '',$_POST['l']);
$p = floatval($_POST['p']);
$QteArticle = array();
$i=0;
if (!empty($_POST['QteArticle'])){
foreach ($_POST['QteArticle'] as $contenu){
$QteArticle[$i++] = intval($contenu);
}
}
else
$q=$_POST['q'];
}
if ($erreur==false){
switch($action){
Case "ajout":
ajouterArticle($l,$q,$p);
break;
Case "suppression":
supprimerArticle($l);
break;
Case "refresh" :
for ($i = 0 ; $i < count($QteArticle) ; $i++)
{
modifierQTeArticle($_SESSION['panier']['libelleProduit'][$i],round($QteArticle[$i]));
}
break;
Default:
break;
}
} |
Partager