-
Notifications
You must be signed in to change notification settings - Fork 0
/
carts.php
108 lines (99 loc) · 4.61 KB
/
carts.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
104
105
106
107
108
<?php
// If the user is logged in, simply redirect them to the dashboard.
require_once "./inc/authchecker.php";
require_once "./inc/config.php";
require_once "./inc/db.php";
require_once("./reusables/head.php");
require_once("./reusables/constants.php");
if ($_SESSION[SESSION_ID_KEY] != "") {
$q="SELECT * FROM ".$subscript."users where aid='".$_SESSION[SESSION_ID_KEY]."'";
$q = $db->query($q);
$q = $db->fetch($q);
function qur($sq1)
{
global $db;
$result = $db->query($sq1);
return $result;
}
$sq1 = "SELECT * FROM " . $subscript . "cart WHERE uid=".$q['uid']."";
?>
<!DOCTYPE html>
<html>
<head>
<?php generateHead(APPNAME." - Cart"); ?>
</head>
<div class="authpage">
<div class ="authpage-main row">
<div class="">
<img
src="./assets/cart.png"
alt="Login"
title="Login"
aria-label="Login"
class="resimage loginimage"
style="margin:0px 250px"
width=20%
height=20%
/>
</div>
<div style="padding-left: 269px;" class ="authpage-main-desc">
<h1 class = "authpage-main-desc-heading">
Cart
</h1><?php
$cat = qur($sq1);
if ($db->numrows($cat) > 0) {?>
<div class = "authpage-form" >
<table class="table table-bordered">
<thead>
<tr>
<th>Product Name</th>
<th>Image</th>
<th>Quantity</th>
<th>Price</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php
$cat = qur($sq1);
foreach ($cat as $i) {
?>
<tr>
<td><?= $i['pname']; ?></td>
<td>
<img src="./images/<?= $i['image'] ?>" width="50px" height="50px" alt="<?= $i['pname']; ?>">
</td>
<td><?= $i['quantity']; ?></td>
<td><?= $i['price']; ?></td>
<td><a href="?h1=delete&hh=<?= $i['pid'] ?>?" class="dangerbutton" onclick="return confirm('Are you sure you want to delete <?= $i['pname'] ?>?')">Delete</td>
<?php
if ($_GET['h1'] == "delete") {
$hh = $_GET['hh'];
$h = $db->query("DELETE FROM " . $subscript . "cart WHERE pid='" . $hh . "'");
header("refresh:0;url=./carts.php?h1=none]");
}
}
?>
</tr>
</tbody>
</table>
<a title="add" class="primarybutton" href="./pay.php">Confirm</a>
<?php
}
else{
echo "No products added in the cart yet..";
}
?>
<a title="Cancel" style="display:flex;" class="dangerbutton" href="./prolist.php?h1=none">Back</a>
</div>
</div>
</div>
</div>
</html>
<?php
}
else{
echo "You Are Not Signed In";
header("refresh:0;url=./login.php");
}
?>