-
Notifications
You must be signed in to change notification settings - Fork 1
/
cart.php
243 lines (184 loc) · 7.55 KB
/
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?php
session_start();
if(!isset($_SESSION["email"])){
header("Location:login.php");
}
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cart - Novatech</title>
<script src="https://kit.fontawesome.com/c37001a085.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="./CSS/style.css">
<link rel="stylesheet" href="./CSS/cart.css">
<link rel="shortcut icon" href="img/mylogo3.png" type="image/x-icon">
</head>
<body>
<section id="header">
<a href="index.php"><img src="./img/sitelogo.png" class="logo"></a>
<div>
<ul id="navbar">
<li><a href="index.php">Home</a></li>
<li><a href="shop.php">Shop</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="profile.php"><i class="fa-solid fa-user"></i></a></li>
<li><a class="active" href="cart.php"><i class="fa-solid fa-cart-shopping"></i></a></li>
</ul>
</div>
</section>
<section id="page-header" class="about-header" style="background-image: url('img/banner/b1.png');">
<h2>Shopping cart</h2>
<p>Add, remove or increase product quantity</p>
</section>
<?php
$con = mysqli_connect("localhost", "root", "", "novatech_database", "3306");
if (!$con) {
die("Sorry, you can't connect to the database.");
}
$sql = "SELECT * FROM `cart_tbl` WHERE `email` = '" . $_SESSION["email"] . "'";
$results = mysqli_query($con, $sql);
$num_results = mysqli_num_rows($results);
if (mysqli_num_rows($results) > 0) {
?>
<section id="cart" class="section-p1">
<table width="100%">
<thead>
<tr>
<td>PRODUCT</td>
<td>NAME</td>
<td>PRICE</td>
<td style='padding-right: 100px;'>QUANTITY</td>
<td></td>
</tr>
</thead>
<?php
while ($row = mysqli_fetch_assoc($results)) {
?>
<tbody>
<tr>
<td><img src="<?php echo $row["imagePath"] ?>"></td>
<td><?php echo $row["productName"]; ?></td>
<td>Rs. <?php echo number_format($row["price"]); ?></td>
<td style='padding-right: 100px;'><input type="number" value="1"></td>
<td>
<form action='DeleteHandler.php?id=<?php echo $row["cartID"]; ?>' method="post">
<button type="submit" class="normal" name="cartDeleteBtn"><i class="fa-solid fa-trash"></i> Remove</button>
</form>
</td>
</tr>
</tbody>
<?php
}
?>
</table>
</section>
<?php
}
?>
<?php
$con = mysqli_connect("localhost", "root", "", "novatech_database", "3306");
if (!$con) {
die("Sorry, you can't connect to the database.");
}
$sql = "SELECT SUM(price) AS total_price FROM `cart_tbl` WHERE `email` = '" . $_SESSION["email"] . "'";
$results = mysqli_query($con, $sql);
$row = mysqli_fetch_assoc($results);
$total_price = $row['total_price'];
?>
<section id="cart-add" class="section-p1">
<div id="address">
<?php
$con = mysqli_connect("localhost", "root", "", "novatech_database", "3306");
if (!$con) {
die("Sorry, you can't connect to the database.");
}
$sql = "SELECT * FROM `user_tbl` WHERE email = '" . $_SESSION['email'] . "'";
$results = mysqli_query($con, $sql);
$user = mysqli_fetch_assoc($results);
?>
<br>
<h3>Shipping details</h3>
<br>
<p style="font-weight: 600; color:black;">Customer name:</p>
<p><?php echo $user["name"]; ?></p><hr>
<p style="font-weight: 600; color:black;">Email address:</p>
<p><?php echo $user["email"]; ?></p><hr>
<p style="font-weight: 600; color:black;">Phone:</p>
<p><?php echo $user["contactNumber"]; ?></p><hr>
<p style="font-weight: 600; color:black;">Address:</p>
<p><?php echo $user["address"]; ?></p>
</div>
<div id="subtotal">
<h3>Payment details</h3>
<table>
<tr>
<td>Cart Subtotal</td>
<td>Rs. <?php echo number_format($total_price); ?></td>
</tr>
<tr>
<td>Shipping</td>
<td>Free</td>
</tr>
<tr>
<td>Tax</td>
<td>Rs. 100</td>
</tr>
<tr>
<td><strong>Total</strong></td>
<td><strong>Rs. <?php echo number_format($total_price + 100); ?></strong></td>
</tr>
</table>
<a href='OrderHandler.php?id=<?php echo $user["userID"]; ?>'>
<button class="normal">Place order</button>
</a>
</div>
</section>
<br><br><br>
<footer class="section-p1">
<div class="col">
<img class="logo-footer" src="img/sitelogo.png">
<h4>Contact</h4>
<p><strong>Address :   </strong>BOC merchant tower, 28 St Michaels Rd, Colombo</p>
<p><strong>Phone :   </strong>+94 74 104 0292</p>
<p><strong>Email :   </strong>[email protected]</p>
<div class="follow">
<h4>Follow us</h4>
<div class="icon">
<i class="fab fa-facebook-f"></i>
<i class="fab fa-instagram"></i>
<i class="fab fa-pinterest"></i>
<a href="https://github.com/ashfaaqrifath/Novatech-Website-Project" target="_blank">
<i class="fab fa-github"></i>
</a>
</div>
</div>
</div>
<div class="col">
<h4>Quick Links</h4>
<a href="shop.php">Shop</a>
<a href="about.html">About us</a>
<a href="contact.html">Contact us</a>
<a href="about.html">Privacy Policy</a>
<a href="about.html">Terms & Conditions</a>
</div>
<div class="col">
<h4>My Account</h4>
<a href="login.php">Sign in</a>
<a href="cart.php">View cart</a>
<a href="profile.php">My wishlist</a>
<a href="profile.php">Order history</a>
</div>
<div class="col install">
<h4>Payment Methods</h4>
<p>Cash on delivery</p>
<p>Secure payment gateway</p>
<img src="img/pay.png">
</div>
<div class="copyright">
<p>Copyright © 2024 Novatech - Developed by <a href="admin.php">Ashfaaq Rifath</a></p>
</div>
</footer>
</body>
</html>