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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
<?php
session_start();
//init des variables
if (!isset($_SESSION['total_commande'])) $_SESSION['total_commande']=0;
if(!isset($_GET['ajoutPanier'])) $ajoutPanier="";//init de ajoutPanier si non déclaré
else $ajoutPanier=$_GET['ajoutPanier'];
if(!isset($_GET['modifPanier'])) $modifPanier="";//init de modifPanier si non déclaré
else $modifPanier=$_GET['modifPanier'];
if(!isset($_GET['suppPanier'])) $suppPanier="";//init de suppPanier si non déclaré
else $suppPanier=$_GET['suppPanier'];
if(!isset($_GET['enregistreCommande'])) $enregistreCommande="";//init de enregistreCommande si non déclaré
else $enregistreCommande=$_GET['enregistreCommande'];
if ((!isset($_SESSION['liste']))&&($ajoutPanier=="")) $liste[]=array("VIDE","","","");//init de liste si VIDE
if (isset($_SESSION['liste'])) $liste=$_SESSION['liste'];//recup de la liste de la session
?>
<?php require_once('Connections/connection.php'); ?>
<?php
mysql_select_db($database_connection, $connection);
//----------------------------------------------------AJOUT PANIER
if ($ajoutPanier=="AJOUTER")
{
$id_produit=$_GET['id_produit'];
$nb=1; //par défaut la quantité est = 1
$prix_actuel=$_GET['prix_actuel'];
$liste[]=array($id_produit,$nb,$prix_actuel,$prix_actuel);
$_SESSION['liste']=$liste;
//ajoute un article à la liste
}
//----------------------------------------------------MODIF PANIER
if ($modifPanier=="ACTUALISER")
{
for ($i=0;$i<count($liste);$i++)
{
$nbi='nb'.$i;
$liste[$i][1]=$_GET["$nbi"];//recup du nbr d'article dans la liste
$liste[$i][3]=$liste[$i][1]*$liste[$i][2];//prixArticle=nbre*prixUnitaire
}
$_SESSION['liste']=$liste;//mAj de la liste
}
//----------------------------------------------------SUPP PANIER
if ($suppPanier=="SUPPRIMER")
{
$produit=$_GET['produit'];
for ($i=0;$i<count($liste);$i++)
{
if($produit==$liste[$i][0])
array_splice($liste,$i,1);
//suppression de l'article
}
$_SESSION['liste']=$liste;//mAj de la liste
}
//----------------------------------------------------COMMANDER
if ($enregistreCommande=="COMMANDER")
{
if(!isset($_GET['action']))
$_SESSION['action']="ENREGISTRER";//mémorise l'action
header("Location: commande.php");
}
if(isset($_REQUEST["action_"])) {
switch($_REQUEST["action_"]) {
case "delog":
//Enlever la cookie
setcookie ("login", "", time() - 3600);
// Destruction de la session
unset($_SESSION["login"]);
session_destroy();
break;
}//fin du switch
} // isset
?>
<html>
<head>
<title>Boutique </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="css/style.css" type="text/css" />
<style type="text/css">
<!--
.Style2 {
font-family: "Times New Roman", Times, serif;
font-weight: bold;
}
.Style3 {color: #993333}
-->
</style>
<SCRIPT LANGUAGE="javascript">
function controle(form1) {
check=confirm("Voulez vous vraiment passer commande");
if(check == false) history.back();
}
</SCRIPT>
</head>
<body>
<div id="Layertitre"> </div>
<img src="image/log.jpg" width="1470" height="170"/>
<div id="Menu">
<table width="160" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#FFFFCC">
<tr>
<td width="160" height="50"><div align="center"><a href="index.html">ACCUEIL</a></td>
</tr>
<tr>
<td width="160" height="50"><div align="center"><a href="soins.html">SOINS/TARIFS</a></td>
</tr>
<tr>
<td width="160" height="50" ><div align="center"><a href="produits.php">PRODUITS</a></td>
</tr>
<tr>
<td width="160" height="50"><div align="center"><a href="contact.php">CONTACT</a></td>
</tr>
<tr>
<td width="160" height="50"><div align="center"><a href="plan.html">PLAN D'ACCES</a></td>
</tr> <p>
<p> </p>
<p> </p>
</table>
</div>
<div id="Layerhaut">
<a href="panier.php">Votre Panier</a> <a href="login.php">S'identifier</a> <a href="inscription.php">S'Inscrire</a> <a href="commande.php">Vos Commandes</a> <a href="login.php?action_=delog">Deconnexion</a> </div>
<div id="Layercontenu">
<table border="0" cellspacing="0">
<tr>
<td><p align="center" class="bodyText Style2"> </p>
<p align="center" class="Style2 bodyText"><em><font size="6">PANIER</font></em></p>
<?php if (isset($_SESSION['liste'])!="") { ?>
<form name="form1" action="panier.php" method="get" >
<table border="1" align="center" cellspacing="0" >
<tr>
<td><table border="0" align="center" cellpadding="0" cellspacing="0">
<tr class="bodyText">
<td width="200"><div align="center"><em> Produit </em></div></td>
<td width="200"><div align="center"><em> Quantité</em></div></td>
<td width="200"><div align="center"><em> Prix</em></div></td>
<td width="50"><div align="center"><em> Supp</em></div></td>
</tr>
<?php
$total_commande=0.00;
for ($i=0;$i<count($liste);$i++)
{
$query_rsPanier="select * from produit where id_produit = '".$liste[$i][0]."'";
//echo $query_rsPanier;
$rsPanier = mysql_query($query_rsPanier, $connection) or die(mysql_error());
$row_rsPanier = mysql_fetch_assoc($rsPanier);
?>
<tr>
<td><div align="center"><?php echo $row_rsPanier['nom_produit'] ?></div></td>
<td><div align="center">
<select name="nb<?php echo $i ?>" id="nb">
<option value="1" <?php if($liste[$i][1]==1) echo "SELECTED"; ?>>1</option>
<option value="2" <?php if($liste[$i][1]==2) echo "SELECTED"; ?>>2</option>
<option value="3" <?php if($liste[$i][1]==3) echo "SELECTED"; ?>>3</option>
</select>
</div></td>
<td><div align="center"><?php echo $row_rsPanier['prix_actuel'] ?></td>
<td><div align="center">
<div align="center"><a href="panier.php?suppPanier=SUPPRIMER&produit=<?php echo $row_rsPanier['id_produit'] ?>"><img src="image/supp.bmp" width="12" height="15" border="0"></a></div>
<td> </td>
</tr>
<?php
$total_commande+=$row_rsPanier['prix_actuel'] * $liste[$i][1];
}
$_SESSION['total_commande']=$total_commande;//mAj du total_commande dans la session
?>
<tr>
<td ><div align="center"></div></td>
<td ><div align="center"></div></td>
<td ><div align="center" class="bodyText"><strong>total_commande: <?php echo $total_commande ?> Euros</strong></div></td>
<td ><div align="center"></div></td>
</tr>
</table></td>
</tr>
</table>
<br>
<p align="center">
<input type="submit" name="modifPanier" value="ACTUALISER">
<input name="enregistreCommande" type="Submit" value="COMMANDER" onClick="controle(form1)">
</p>
<p align="center" class="bodyText"><a href="produits.php"><em>Retour aux produits </em></a></p>
</form>
<?php } //fin du if
if (!isset($_SESSION['liste']))
{
?>
<p align="center" class="bodyText"><strong>Votre panier est vide</strong></p>
<?php }?> </td>
</tr>
</table>
</div>
</body>
</html> |
Partager