-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.php
342 lines (292 loc) · 12.5 KB
/
index.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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<?php
include 'connection.php';
include 'header.php';
?>
<html>
<script src="https://kit.fontawesome.com/c3f1d5478b.js" crossorigin="anonymous"></script>
<body>
<!-- SIdeNav Mobile -->
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<input type="text" id="mySearch" onkeyup="myFunction()" placeholder="Search.." title="Type in a category">
<a href="showcase.php?cat=">Dresses</a>
<a href="showcase.php?cat=">Jeans</a>
<a href="showcase.php?cat=">Jackets</a>
<a href="showcase.php?cat=">Tops</a>
</div>
<!-- Script for SideNav Mobile -->
<script>
function openNav() {
if (document.getElementById("mySidenav").style.width == "250px") {
document.getElementById("mySidenav").style.width = "0";
} else {
document.getElementById("mySidenav").style.width = "250px";
}
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}
</script>
<!-- Slideshow container -->
<div class="slideshow-container">
<!-- Full-width images with number -->
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<a href="showcase.php?cat="><img src="cover/cov (1).jpg"></a>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<a href="showcase.php?cat="><img src="cover/cov (2).jpg"></a>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<a href="showcase.php?cat="> <img src="cover/cov (3).jpg"></a>
</div>
</div>
<br>
<!-- The dots/circles -->
<div class="dotclass" style="text-align:center">
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
</div>
<!--Script for SlideShow-->
<script>
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {
slideIndex = 1
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex - 1].style.display = "block";
dots[slideIndex - 1].className += " active";
setTimeout(showSlides, 4000); // Change image every 4 seconds
}
</script>
<!--Product Slideshow-->
<h2 id="pproductscont" style="text-align:center;">POPULAR PRODUCTS</h2>
<div class="productslideshow-container">
<div class="productmySlides">
<div class="products">
<?php
$sql = "SELECT pro_id, pro_name, price, pro_img FROM products WHERE pro_id < 6";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo '<form class="card" method="post" action="">
<input type="hidden" name="p_id" value="' .$row["pro_id"]. '" />
<a href="product.php?' . $row["pro_id"] . '">
<div class="picontainer">
<img src="'.$row["pro_img"].'" alt="Red Kurta" class="pimage">
<div class="poverlay">' . $row["pro_name"] . ' | ' . $row["price"] .'</div>
<div class="proid" style="display:none">' . $row["pro_id"] . '</div>
</div>
</a>
<button type="submit" class="add-to-cart">Add to Cart</button>
</form>';
}
}
?>
</div>
</div>
<div class="productmySlides">
<div class="products">
<?php
$sql1 = "SELECT pro_id, pro_name, price, pro_img FROM products WHERE pro_id > 5 LIMIT 5";
$result1 = $conn->query($sql1);
if ($result1->num_rows > 0) {
// output data of each row
while($row = $result1->fetch_assoc()) {
echo '<form class="card" method="post" action="">
<input type="hidden" name="p_id" value="' .$row["pro_id"]. '" />
<a href="product.php?' . $row["pro_id"] . '">
<div class="picontainer">
<img src="'.$row["pro_img"].'" alt="Red Kurta" class="pimage">
<div class="poverlay">' . $row["pro_name"] . ' | ' . $row["price"] .'</div>
<div class="proid" style="display:none">' . $row["pro_id"] . '</div>
</div>
</a>
<button type="submizt" class="add-to-cart">Add to Cart</button>
</form>';
}
}
?>
</div>
</div>
<a class="prev " onclick="pplusSlides(-1) ">❮</a>
<a class="next " onclick="pplusSlides(1) ">❯</a>
</div>
<?php
$cust_id = 0;
if(!empty($_SESSION["loggedin"])){
$cust_id = $_SESSION["id"];
}
if (isset($_POST['p_id']) && $_POST['p_id']!="" && $cust_id!=0){
$code = $_POST["p_id"];
$in = true;
$q = "SELECT pro_id, ordered FROM cart WHERE cus_id = $cust_id";
$r = $conn->query($q);
if ($r->num_rows > 0) {
while($ro = $r->fetch_assoc()) {
if($ro["pro_id"] == $code && $ro["ordered"] == 0)
{
$in = false;
$que = "UPDATE cart SET pro_quantity = pro_quantity + 1 WHERE cus_id = $cust_id AND pro_id = $code";
if($res = mysqli_query($conn, $que)) {
echo '<div id="NotiWindow" class="Notimodal">
<div class="Notimodal-content">
<span class="Noticlose">×</span>
<p>Already Added! Quantity Updated.</p>
</div>
</div>';
} else {
echo '<div id="NotiWindow" class="Notimodal">
<div class="Notimodal-content">
<span class="Noticlose">×</span>
<p>Error: ' . $sql . '<br>' . $conn->error . '</p>
</div>
</div>';
}
}
}
}
if($in)
{
$query = "INSERT INTO cart (cus_id, pro_id) VALUES ($cust_id, $code)";
if($result = mysqli_query($conn, $query)) {
echo '<div id="NotiWindow" class="Notimodal">
<div class="Notimodal-content">
<span class="Noticlose">×</span>
<p>Added to Cart!</p>
</div>
</div>';
} else {
echo '<div id="NotiWindow" class="Notimodal">
<div class="Notimodal-content">
<span class="Noticlose">×</span>
<p>Error: ' . $sql . '<br>' . $conn->error . '</p>
</div>
</div>';
}
}
}
else
{
if($cust_id==0 && isset($_POST['p_id']))
{
echo '<div id="NotiWindow" class="Notimodal">
<div class="Notimodal-content">
<span class="Noticlose">×</span>
<p>Not Logged In!</p>
</div>
</div>';
}
}
?>
<!-- Script for NotiWindow-->
<script>
// Get the modal
var modal = document.getElementById("NotiWindow");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("Noticlose")[0];
// When the user clicks the button, open the modal
function displayNoti() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
<!-- Script for Add to Cart Button -->
<script>
i = 0;
addToCartButton = document.querySelectorAll(".add-to-cart");
document.querySelectorAll('.add-to-cart').forEach(function(addToCartButton) {
addToCartButton.addEventListener('click', function() {
if (addToCartButton.innerHTML == "Added!") {
addToCartButton.innerHTML = "Add to Cart";
document.getElementById("cart-quantity").innerHTML = i -= 1;
} else {
addToCartButton.innerHTML = "Added!";
document.getElementById("cart-quantity").innerHTML = i += 1;
}
});
});
</script>
<div class="dot-container ">
<span class="dot " onclick="pcurrentSlide(1) "></span>
<span class="dot " onclick="pcurrentSlide(2) "></span>
</div>
<!--Script for Products SLideshow-->
<script>
var pslideIndex = 1;
pshowSlides(pslideIndex);
function pplusSlides(n) {
pshowSlides(pslideIndex += n);
}
function pcurrentSlide(n) {
pshowSlides(pslideIndex = n);
}
function pshowSlides(n) {
var i;
var slides = document.getElementsByClassName("productmySlides ");
var dots = document.getElementsByClassName("dot ");
if (n > slides.length) {
pslideIndex = 1
}
if (n < 1) {
pslideIndex = slides.length
}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none ";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active ", " ");
}
slides[pslideIndex - 1].style.display = "block ";
dots[pslideIndex - 1].className += " active ";
}
</script>
<!--Shop By Category Section-->
<h2 style="text-align:center;">SHOP BY CATEGORY</h2>
<div class="category-group">
<a href="showcase.php?cat=3"><img src="Jeans.png" style="width:100%">
<h4>JEANS</h4>
</a>
<a href="showcase.php?cat=2"><img src="Tops.png" style="width:100%">
<h4>TOPS</h4>
</a>
<a href="showcase.php?cat=1"><img src="Dresses.png" style="width:100%">
<h4>DRESSES</h4>
</a>
<a href="showcase.php?cat=5"><img src="Jackets.png" style="width:100%">
<h4>JACKETS</h4>
</a>
<a href="showcase.php?cat=4"><img src="Pants.png" style="width:100%">
<h4>PANTS</h4>
</a>
<a href="showcase.php?cat=6"><img src="Accessories.png" style="width:100%">
<h4>ACCESSORIES</h4>
</a>
</div>
<?php require_once "footer.php"; ?>
</body>
</html>