This repository has been archived by the owner on Aug 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shopping-cart.php
103 lines (80 loc) · 4.27 KB
/
shopping-cart.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
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
<?php include("php/check-login.php"); ?>
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Carrello</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous" />
<link rel="stylesheet" href="assets/css/shopping-cart.css" />
</head>
<body>
<?php include("components/navbar.php"); ?>
<div class="shopping-cart d-flex justify-content-center align-items-center flex-column">
<div class="container-md text-center mt-5 py-5">
<div class="container-md text-white bg-dark rounded w-50 mt-2 py-2">
<h3>Resoconto:</h3>
<div class="d-flex flex-column">
<span>Elementi:
<?php
require("php/config.php");
if($connection) {
$email = $_SESSION["email"];
$q = "SELECT email, count(*) AS totale FROM carrello_utente WHERE email=$1 GROUP BY email";
$result = pg_query_params($connection, $q, array($email));
$totale = pg_fetch_all($result);
if($totale) {
for($i = 0; $i < count($totale); $i++) {
$libri = $totale[$i]["totale"];
}
echo $libri;
} else {
echo "vuoto";
}
}
?>
</span>
<span>prezzo:
<?php
require("php/config.php");
if($connection) {
$email = $_SESSION["email"];
$q = "SELECT prezzo FROM carrello_utente WHERE email=$1";
$result = pg_query_params($connection, $q, array($email));
$totale = pg_fetch_all($result);
$prezzo_complessivo = 0;
if($totale) {
for($i = 0; $i < count($totale); $i++) {
$prezzo_complessivo = $prezzo_complessivo + floatval($totale[$i]["prezzo"]);
}
}
echo $prezzo_complessivo;
}
?>
€
</span>
</div>
</div>
</div>
<div class="container-md row pb-3">
<?php include("php/shopping-cart.php"); ?>
</div>
<div class="d-flex justify-content-center align-items-center w-100 my-3">
<a href="./payment.php" class="icon btn btn-success mx-3 p-3"><i class="fa-solid fa-credit-card"></i></a>
<a href="php/cancella.php" class="icon btn btn-danger mx-3 p-3"><i class="fa-solid fa-trash"></i></a>
<a href="./welcome.php" class="icon btn btn-primary mx-3 p-3"><i class="fa-solid fa-house"></i></a>
</div>
</div>
<?php include("components/footer.php"); ?>
<?php include("components/arrow.php"); ?>
<!-- Bootstrap JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<!-- Font Awesome JavaScript -->
<script src="https://kit.fontawesome.com/f461cd1aac.js" crossorigin="anonymous"></script>
<!-- Jquery JavaScript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<!-- Checkout JavaScript -->
<script src="../assets/js/index.js"></script>
</body>
</html>