-
Notifications
You must be signed in to change notification settings - Fork 1
/
addbag.php
37 lines (26 loc) · 813 Bytes
/
addbag.php
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
<?php
include 'connection.php';
session_start();
$user = $_SESSION['login'];
$quantite = 0;
$ref = $_REQUEST['ref'];
$sql = "SELECT reference, quantite_d_article FROM pannier WHERE mail_login = '".$user."'
AND reference = '".$ref."'";
$table = $connection->query($sql);
echo $sql;
while ($ligne = $table->fetch()){
if ($ligne['reference'] =$ref){
$quantite = $ligne['quantite_d_article'] + 1;
}
}
if ($quantite != 0){
$sql = "UPDATE `pannier` SET `quantite_d_article`= ".$quantite."
WHERE mail_login = '".$user."' AND reference = '".$ref."'";
}else {
$quantite = 1;
$sql = "INSERT INTO `pannier` (`mail_login`, `reference`, `quantite_d_article`)
VALUES ('".$user."', '".$ref."', ".$quantite.")";
}
$connection->exec($sql);
header("location: afficher_panier.php");
?>