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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<?php
session_start();
//init des variables
if (!isset($_SESSION['total'])) $_SESSION['total']=0;
if(!isset($_GET['ajout'])) $ajout="";//init de ajoutPanier si non déclaré
else $ajout=$_GET['ajout'];
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']))&&($ajout=="")) $liste[]=array("VIDE",1,0,0);//init de liste si VIDE
if (isset($_SESSION['liste']))
$liste=$_SESSION['liste'];//recup de la liste de la session
$hostname_connectionebook = "localhost";
$database_connectionebook = "ebook";
$username_connectionebook = "root";
$password_connectionebook = "";
$ebook = mysql_connect($hostname_connectionebook, $username_connectionebook, $password_connectionebook) or die(mysql_error());
mysql_select_db('ebook',$ebook);
//----------------------------------------------------AJOUT PANIER
if ($ajout == "AJOUT")
{
$idLivre=$_GET['idLivre'];
$nb=1; //par défaut la quantité est = 1
$prix=$_GET['prix'];
$liste[]=array($idLivre,$nb,$prix,$prix);
$_SESSION['liste']=$liste;
}
//ajoute un article à la liste
//----------------------------------------------------MODIF PANIER
if ($modifPanier=="ACTUALISER" )
{
$article=$_GET['article'];
$prix=$_GET['prix'];
$nbprod=count($_SESSION['liste']);
printf($nbprod);print_r($_SESSION);
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
printf($article);
print($modifPanier);
}
//----------------------------------------------------SUPP PANIER['
if ($suppPanier=="SUPPRIMER")
{
$article=$_GET['article'];
for ($i=0;$i<count($liste);$i++)
{
if($article==$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");
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
@import url(../css/mise_en_page_bis.css);
@import url(../css/formulaire.css);
</style>
</head>
<body>
<div id="conteneur">
<div id="header1"> <img src="images/sbpp007.jpg"/>
<p>E-Book.com</p>
</div>
<div id="header2">
<ul id="menuDeroulant">
<li> <a href="#">Accueil</a> </li>
<li> <a href="#">Informatique</a>
<ul class="sousMenu">
<li><a href="#">Base de données</a></li>
<li><a href="#">Java</a></li>
<li><a href="#">WEB</a></li>
</ul>
</li>
<li> <a href="#">Audiovisuel et graphisme</a>
<ul class="sousMenu1">
<li><a href="#">Photographie</a></li>
<li><a href="#">Graphisme</a></li>
</ul>
</li>
<li> <a href="#">Sciences</a>
<ul class="sousMenu2">
<li><a href="#">Physique</a></li>
<li><a href="#">Chimie</a></li>
<li><a href="#">Biologie</a></li>
</ul>
</li>
</ul>
</div>
<div id="header3">
<form action="rechercher.php" method ="get" id="recherche" class="form_header">
<p>
<label for="recherche_rapide">RECHERCHE : </label>
<input type="text" name="recherche_rapide" id="recherche_rapide" size="16" />
</p>
<p>
<select name="theme" id="theme" >
<option value="ts">Tous les thèmes</option>
<option value="inf">Informatique</option>
<option value="sci">Sciences</option>
<option value="droit">Droit</option>
<option value="btp">BTP et Construction</option>
</select>
</p>
<p>
<input type="submit" name="recherche" value="OK" />
</p>
<p> <a href="recherche_detaillee.html">Recherche détaillée</a> </p>
</form>
</div>
<div id="header4">
<p> <img src="images/puce3.gif"/><a href="#">Nouveautés</a> <img src="images/puce3.gif"/><a href="#">Thèmes</a>
<img src="images/puce3.gif"/><a href="#">Meilleures ventes</a> </p>
</div><div id="menu_gauche">
<div class="item">
<form action="identifier.php" method="post" id="identification" >
<h1>Votre compte</h1>
<p>
<label for="email">E-mail : </label>
<input type="text" name="email" id="email" size="16" />
</p>
<p>
<label for="motpasse">Mot de passe : </label>
<input type="password" name="motpasse" id="motpasse" size="10" />
<input type="submit" value="OK" name="identifiant"/>
</p>
</form>
<ul>
<li><a href="">Mot de passe oublié?</a></li>
<li><a href=""><strong>Inscrivez-vous maintenant gratuitement!</strong></a></li>
</ul>
</div>
<div class="aide">
<h1>AIDE</h1>
<ul>
<li><a href="#">Trouver un article</a></li>
<li><a href="#">Frais de port et délais</a></li>
<li><a href="#">Commander</a></li>
<li><a href="#">Paiement</a></li>
<li><a href="#">Sécurité</a></li>
<li><a href="#">Suivi de commande</a></li>
</ul>
<ul>
<li><a href="#">Nous contacter</a></li>
<li><a href="#">Venir à la librairie</a></li>
</ul>
</div>
</div>
<div id="corps" class="marginright">
<p class="titre">Panier</p>
<p class="center"><img src="images/etape_panier.gif"/></p>
<form action="panier.php" method="get" name="recherche" id="recherche" class="form_commander">
<h3>Votre panier : </h3>
<table class="panier">
<tr class="lignepanierheader">
<th align="left">Articles</th>
<th >Quantité</th>
<th >Prix Unitaire</th>
<th >Montant</th>
<td></td>
</tr>
<tr class="interlignepanier"><td></td></td></tr>
<?php
$total=0.00;
for ($i=0;$i<count($liste);$i++){
$query_rsPanier="select * from livre where idLivre = '".$liste[$i][0]."'";
$rsPanier = mysql_query($query_rsPanier, $ebook) or die(mysql_error());
$row_rsPanier = mysql_fetch_assoc($rsPanier);
$_SESSION['titre']=$row_rsPanier['titre'];
?>
<tr class="lignepanier">
<td align="left"><?php echo $row_rsPanier['idLivre'];?></td>
<td>
<select name="nb<?php echo $i ?>" id="nb">
<option value="1" <?php if($_SESSION['liste'][$i][1]==1) echo "SELECTED"; ?>>1</option>
<option value="2" <?php if($_SESSION['liste'][$i][1]==2) echo "SELECTED"; ?>>2</option>
<option value="3" <?php if($_SESSION['liste'][$i][1]==3) echo "SELECTED"; ?>>3</option>
</select>
<input type="hidden" name="article" value="<?php echo $row_rsPanier['idLivre'];?>"/>
<input type="hidden" name="prix" value="<?php echo $row_rsPanier['prix_eyrolles'];?>"/>
</td>
<td><?php echo $row_rsPanier['prix_eyrolles'];
?>
</td>
<td><?php echo $row_rsPanier['prix_eyrolles'] * $_SESSION['liste'][$i][1]?> EUR</td>
<td align="right">
<img src="images/mettredecote.gif"/><br/>
<a href="panier.php?suppPanier=SUPPRIMER&article=<?php echo $row_rsPanier['idLivre'] ?>">
<img src="images/supprimerpanier.gif"/>
</a>
</td>
</tr>
<?php
$total+=$row_rsPanier['prix_eyrolles'] * $_SESSION['liste'][$i][1];
$_SESSION['total']=$total;//mAj du total dans la session
?>
<tr class="interlignepanier"><td></td></tr>
<tr class="lignepanierbottom">
<td align="left">TOTAL </td>
<td></td>
<td></td>
<td><?php echo $total ?> EUR</td>
</tr>
</table>
<p>
Vous avez modifié une quantité?
</p>
<p class="form">
<input type="image" src="images/mettreajour_panier.gif" name="modifPanier" value="ACTUALISER"/><?php }?>
</p>
<p class="form">
<input type="image" src="images/vider_panier.gif" name="viderpanier" id="viderpanier" value="Vider panier"/>
</p>
<a href="resultat_recherche.php"><img src="images/continuer.gif"/></a>
<p>
<input type="image" src="images/commander.gif" name="enregistreCommande" id="commander" value="Commander"/></p>
</td>
</form>
<p style="background:#efefef;padding:2px;text-align:center">
<strong><span style="color:red">Promotion :</span></strong> Frais de port offerts à partir de 49 EUR d'achats.
<span style="font-size:0.8em">(livraison en France métropolitaine)</span>.</p>
</div>
<div id="footer"> E-Book.com </div>
</div>
</body> <?php
?> |
Partager