This repository was archived by the owner on Aug 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout.php
More file actions
100 lines (88 loc) · 2.44 KB
/
checkout.php
File metadata and controls
100 lines (88 loc) · 2.44 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
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
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script>
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive
}
var minutes = getRandomInt(1, 6);
let timeLeft = (minutes * 60); // x minutes in seconds
function updateTimer() {
var ah = document.getElementById("popup");
const timer = document.getElementById("timer");
if (getComputedStyle(ah).display !== "none") {
const minutes = Math.floor(timeLeft / 60);
const seconds = timeLeft % 60;
timer.textContent = `in ${minutes}:${seconds < 10 ? '0' : ''}${seconds} min`;
if (timeLeft > 0) {
timeLeft--;
setTimeout(updateTimer, 1000);
} else {
timer.textContent = "right now!";
ah.classList.toggle("done");
}
}
}
</script>
<style>
.outer {
display: flex;
justify-content: space-between;
}
</style>
</head>
<html>
<body>
<div id="bg" style="display: none;">
<div id="popup">
<div id="box">📦</div>
<p>Your products are being delivered <span id="timer"></span></p>
<form method="post" action="clear2.php">
<button type="submit" class="down">Okay</button>
</form>
</div>
</div>
<?php
include "config.php";
include "header.php";
echo "<div style='
float: unset;
padding: 5pt;
padding-left: 10px ;
margin: 5pt;'>";
echo "<h2>Shopping Cart</h2>";
echo "<div class='outer'>";
echo "<div><strong>Name</strong></div>";
echo "<div><strong>Price (kr)</strong></div>";
echo "</div>";
$sql = "SELECT * FROM Purchases;";
$result = $conn->query($sql);
// Check if there are any products
if ($result->num_rows > 0) {
// Output data of each row
while ($row = $result->fetch_assoc()) {
// Display product as a receipt
echo "<div class='outer'>";
echo "<div>" . $row["Name"] . "</div>";
echo "<div>" . $row["Price"] . "</div>";
echo "</div>";
}
echo "<button onmousedown='popuptoggle(), updateTimer()'>Checkout</button></form>";
} else {
header("location: store.php");
}
?>
</body>
</html>
<script>
function popuptoggle() {
var x = document.getElementById("bg");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
</script>