-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathorder_now.php
More file actions
71 lines (59 loc) · 1.67 KB
/
order_now.php
File metadata and controls
71 lines (59 loc) · 1.67 KB
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
<?php
session_start();// taadi des variables fi koll page
require "./DbConnect/index.php";
$page_titel = "page d'acceill";
if(!isset($_SESSION['carte'])){
$_SESSION['carte']=array();
}else{
$_SESSION['carte']=$_SESSION['carte'];
}
//var_dump($_SESSION['carte']);
if(isset($_GET['id'])){
$res = $db->prepare("select * from produits where id=?");
$res->execute([$_GET['id']]);
$produit = $res->fetch();
$idProduit=$_GET['id'];
$Quantity=1;
$trouve=-1;
for($i=0;$i<=count($_SESSION['carte']);$i++){
if(isset($_SESSION['carte'][$i])){
if($_SESSION['carte'][$i][0]==$idProduit){
$trouve=$i;
}
}
}
if($trouve!=-1){
for($i=0;$i<=count($_SESSION['carte']);$i++){
if(isset($_SESSION['carte'][$i])){
if($_SESSION['carte'][$i][0]==$idProduit){
$_SESSION['carte'][$i][1]++;
}
}
}
$trouve=-1;
}else{
array_push($_SESSION['carte'],[$idProduit,$Quantity,$produit['prix'],$produit['nom'],$produit['PhotoProduit']]);
}
}
if(isset($_GET['DeleteProd'])){
$trouve=-1;
for($i=0;$i<count($_SESSION['carte']);$i++){
if(isset($_SESSION['carte'][$i])){
if($_SESSION['carte'][$i][0]==$_GET['DeleteProd']){
$trouve=$i;
}
}
}
if(count($_SESSION['carte'])==1){
unset($_SESSION['carte']);
$_SESSION['carte']=array();
}else{
unset($_SESSION['carte'][$trouve]);
}
}
$res = $db->prepare("select * from categories");
$res->execute();
$categories = $res->fetchAll();
$template = "";
include "./layout.phtml";
?>