bonsoir a tous,
j'ai une probleme lors de l'ajout des produits au pannier..
le client doit s'authentifier avant d'ajouter des produits mais ca ne marche pas...
le probleme est que quelle que soit la personne elle peut ajouter des produits mais c'est pas ca..
Voici le code de panier:
<?php
if(isset($_SESSION['nomclient']))
{
include_once("./login.php");
//secho 'test';
if(isset($_GET['reference']))
{
$r=$_GET['reference'];
$n=$_GET['nomproduit'];
$d=$_GET['description'];
$p=$_GET['prix'];
$q=$_GET['quantite'];
$c=$_GET['categorie'];
$m=$_GET['marque'];
$pr=$_GET['promotion'];
if(!isset($_SESSION['panier']))
{
$_SESSION['panier']=array();
$_SESSION['panier']['reference']=array();
$_SESSION['panier']['nomproduit']=array();
$_SESSION['panier']['description']=array();
$_SESSION['panier']['prix']=array();
$_SESSION['panier']['quantite']=array();
$_SESSION['panier']['categorie']=array();
$_SESSION['panier']['marque']=array();
$_SESSION['panier']['promotion']=array();
array_push($_SESSION['panier']['reference'],$r);
array_push($_SESSION['panier']['nomproduit'],$n);
array_push($_SESSION['panier']['description'],$d);
array_push($_SESSION['panier']['prix'],$p);
array_push($_SESSION['panier']['quantite'],1);
array_push($_SESSION['panier']['categorie'],$c);
array_push($_SESSION['panier']['marque'],$m);
array_push($_SESSION['panier']['promotion'],$pr);
}
else // else de if panier
{
//$stack=array(1,2);
if(! in_array($r,$_SESSION['panier']['reference']))
{
array_push($_SESSION['panier']['reference'],$r);
array_push($_SESSION['panier']['nomproduit'],$n);
array_push($_SESSION['panier']['description'],$d);
array_push($_SESSION['panier']['prix'],$p);
array_push($_SESSION['panier']['quantite'],1);
array_push($_SESSION['panier']['categorie'],$c);
array_push($_SESSION['panier']['marque'],$m);
array_push($_SESSION['panier']['promotion'],$pr);
}
else
{
//echo 'test2';
$key = array_search($r,$_SESSION['panier']['reference']);
//echo $key;
$_SESSION['panier']['quantite'][$key]=$_SESSION['panier']['quantite'][$key]+1;
}
//print_r ($_SESSION['panier']['ref']);
}
}
if(isset($_SESSION['panier']))
{
echo '<pre>';
//print_r ($_SESSION); pour afficher la totalite de session
echo '<pre>';
echo "<center><table border=1>";
echo "<tr bgcolor=\"#FF9966\"><td>Reference</td><td>Nom</td><td>description</td><td>Prix</td><td>quantité</td><td>categorie</td><td>marque</td><td>promotion</td></tr>";
for($i=0;$i<count($_SESSION['panier']['reference']);$i++)
{
echo "<tr> <td>".$_SESSION['panier']['reference'][$i]."</td> <td>".$_SESSION['panier']['nomproduit'][$i]."</td><td>".$_SESSION['panier']['description'][$i]."</td><td>". $_SESSION['panier']['prix'][$i]."</td><td>".$_SESSION['panier']['quantite'][$i].
"</td><td>".$_SESSION['panier']['categorie'][$i]."</td><td>".$_SESSION['panier']['marque'][$i]."</td><td>".$_SESSION['panier']['promotion'][$i]."</td></tr>";
}
echo "</table></center>";
echo "<center><a href=\"panier.php?mode=vider\">vider le panier</a></center><br>";
if(isset($_GET['mode']) and ($_GET['mode']=='vider'))
{
//session_destroy($_SESSION['panier']);
$_SESSION['panier']=array();
unset($_SESSION['panier']);
?>
<script language="javascript" type="text/jscript">
document.location.reload();
</script>
<?php
}
}
else{
echo "ressource non autorisée, veuillez vous identifier!";
}
?>
j'ai besoin de votre aide
merci d'avance
