-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
551 lines (529 loc) · 35.2 KB
/
Copy pathindex.php
File metadata and controls
551 lines (529 loc) · 35.2 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
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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
<?php
require "./includes/dbh.inc.php";
include('./functions/functions.php');
session_start();
$userID = $_SESSION['userId'];
// print($userID);
$selectQuery = "SELECT * FROM cart WHERE userID='$userID'";
$check = mysqli_query($conn, $selectQuery);
while ($row = mysqli_fetch_array($check)) {
$partID = $row['productid'];
$partquery = "SELECT * FROM pcpart WHERE pcPartID='$partID'";
$checkpart = mysqli_query($conn, $partquery);
$count = mysqli_num_rows($checkpart);
while($partrow = mysqli_fetch_array($checkpart)){
$grandTotal += $partrow['price'];
}
}
$getCart = "SELECT * FROM pccart WHERE userid='$userID'";
$runGetCart = mysqli_query($conn, $getCart);
while($row = mysqli_fetch_array($runGetCart)){
$productID = $row['pcid'];
$quantity = 1;
$getproduct = "SELECT * FROM pc_details WHERE pc_id='$productID'";
$rungetProduct = mysqli_query($conn, $getproduct);
while($productrow = mysqli_fetch_array($rungetProduct)){
$grandTotal += $_SESSION['grandtotal'];
}
}
if(isset($_GET['delaccount'])){
$deleteaccount = "DELETE FROM users WHERE isUsers='$userID';";
$check = mysqli_query($conn, $deleteaccount);
$deleteorder = "DELETE FROM orders WHERE userID='$userID';";
$checkorder = mysqli_query($conn, $deleteorder);
$deletecart = "DELETE FROM cart WHERE userID='$userID'";
$checkcart = mysqli_query($conn, $deletecart);
$deletesb = "DELETE FROM sborders WHERE userID='$userID'";
$checksb = mysqli_query($conn, $deletesb);
$deletesbpc = "DELETE FROM sbpc WHERE userID='$userID'";
$checksbpc = mysqli_query($conn, $deletesbpc);
if($check and $checkorder and $checkcart and $checksb and $checksbpc){
header("LOCATION: includes/logout.inc.php");
}
else{
header("LOCATION: ./index.php");
}
}
?>
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Computer-Store</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/png" href="img/favicon.png" >
<link rel="stylesheet" href="./style.css">
<link rel="stylesheet" href="./customstyle.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.10.2/css/all.css" integrity="sha384-rtJEYb85SiYWgfpCr0jn174XgJTn4rptSOQsMroFBPQSGLdOC5IbubP6lJ35qoM9" crossorigin="anonymous">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
jQuery(document).ready(function() {
jQuery('.toggle-nav').click(function(e) {
jQuery(this).toggleClass('active');
jQuery('.menu ul').toggleClass('active');
e.preventDefault();
});
});
function showHide(){
var click = document.getElementById("dropdown-content");
if(click.style.display === "none"){
click.style.display = "block";
}
else{
click.style.display = "none";
}
}
function currentDiv(n) {
showDivs(slideIndex = n);
}
</script>
</head>
<body>
<!-- Navbar -->
<div style="position:sticky;top:0px;z-index:1;height:8%;" class="d-flex flex-col w-100 white shadow-sm">
<div class="d-flex jcsb">
<div class="d-flex flex-row">
<div>
<a href="indexcopy.php"><img class="img1" src="img/cpu.png" alt=""></a>
</div>
<div class="hamburger">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
<div class="menu">
<ul class="ls-none active current-item">
<li class="p-1"><a class="pl-1 text-deco-none text-black nav" href="index.php?home">Home</a></li>
<li class="p-1"><a class="pl-1 text-deco-none text-black nav" href="builds/system-build.php">SystemBuild</a></li>
<li class="p-1"><a class="pl-1 text-deco-none text-black nav" href="builds/completed_build.php">CompletedBuild</a></li>
<li class="p-1">
<div class="dropdown">
<a style="cursor:pointer" class="pl-1 text-deco-none text-black nav" onclick="showHide()">Catergories</a>
<div style="display:none;" id="dropdown-content" class="dropdown-content shadow-sm text-center mr-2">
<div class="d-flex flex-wrap p-sm">
<div style="background:#e0e0e0;" class="m-1" >
<a href="index.php?showpart=2">
<div class="d-flex flex-col">
<img width="100" src="./img/nav-cpu.png" alt="cpu">
<p class="text-center">CPU</p>
</div>
</a>
</div>
<div style="background:#e0e0e0" class="m-1" >
<a href="index.php?showpart=1">
<div class="d-flex flex-col">
<img width="100" src="./img/nav-case.png" alt="case">
<p class="text-center">Case</p>
</div>
</a>
</div>
<div style="background:#e0e0e0" class="m-1" >
<a href="index.php?showpart=5">
<div class="d-flex flex-col">
<img width="100" src="./img/nav-memory.png" alt="ram">
<p class="text-center">RAM</p>
</div>
</a>
</div>
<div style="background:#e0e0e0" class="m-1" >
<a href="index.php?showpart=9">
<div class="d-flex flex-col">
<img width="100" src="./img/nav-ssd.png" alt="ssd">
<p class="text-center">Harddisk</p>
</div>
</a>
</div>
<div style="background:#e0e0e0" class="m-1" >
<a href="index.php?showpart=6">
<div class="d-flex flex-col">
<img width="100" src="./img/nav-videocard.png" alt="videocard">
<p class="text-center">Graphics Card</p>
</div>
</a>
</div>
<div style="background:#e0e0e0" class="m-1" >
<a href="index.php?showpart=7">
<div class="d-flex flex-col">
<img width="100" height="100" src="./img/nav-mouse.png" alt="mouse">
<p class="text-center">Mouse</p>
</div>
</a>
</div>
<div style="background:#e0e0e0" class="m-1" >
<a href="index.php?showpart=8">
<div class="d-flex flex-col">
<img width="140" height="100" src="./img/nav-keyboard.png" alt="keyboard">
<p class="text-center">Keyboard</p>
</div>
</a>
</div>
<div style="background:#e0e0e0" class="m-1" >
<a href="index.php?showpart=4">
<div class="d-flex flex-col">
<img width="140" height="100" src="./img/nav-monitor.png" alt="monitor">
<p class="text-center">Monitor</p>
</div>
</a>
</div>
<div style="background:#e0e0e0" class="m-1" >
<a href="index.php?showpart=3">
<div class="d-flex flex-col">
<img width="140" height="100" src="./img/nav-motherboard.png" alt="motherboard">
<p class="text-center">Motherboard</p>
</div>
</a>
</div>
</div>
<div class="d-flex jcsa">
<div class="text-left m-1">
<a style="color:#28AB87" href="index.php?secpart">Second Hand Parts</a>
</div>
<div class="text-left m-1">
<a style="color:#28AB87" href="index.php?secpc">Second Hand PC</a>
</div>
</div>
</div>
</div>
</li>
<li class="p-1"><a class="pl-1 text-deco-none text-black nav" href="about.php">About</a></li>
<li class="p-1"><a class="pl-1 text-deco-none text-black nav" href="contact.php">Contact</a></li>
</ul>
</div>
<div>
<a class="toggle-nav" href="#">☰</a>
</div>
</div>
<div class="mt-sm">
<?php
loginORnot();
?>
</div>
</div>
<div style=" background:gray">
<?php
$userName = $_SESSION['userUid'];
if($_SESSION['userId']){
echo'
<div class="p-sm '?><?php if(isset($_GET["close"])){echo "close";} echo'">
<div style="">
<div class="container d-flex flex-row jcc">
<div style="background:#28AB87" class="text-white p-sm b-rad-2">
Welcome! '?><?php echo $userName; echo'
</div>
'?>
<?php
if ($count == 0){
echo'
<div class="text-white m-sm">Fill ur Bucket'?><?php echo $userName; echo' ! Many offers are on!! </div>
<div class=" ml-2">
<a href="index.php?close">
<button class="" style="padding:6px;color:#28AB87;" name="close">✖</button>
</a>
</div>
</div>
</div>
</div>
';
}
else{
echo'
<div class="text-white m-sm">
'?><?php cartcount(); echo' Items in your cart
</div>
<div style="border:1px solid white; height:20px; margin:10px;"></div>
<div class="text-white my-sm">
Total Price: ₹ '?><?php echo $grandTotal; echo'
</div>
<div class=" ml-2">
<a href="index.php?close">
<button class="" style="padding:6px;color:#28AB87;" name="close">✖</button>
</a>
</div>
</div>
</div>
</div>
';
}
}
?>
</div>
</div>
<!-- Navbar -->
<!-- Content -->
<div class="primary bg-color md-m-0 md-p-0 pt-1 sm-p-0">
<div class="d-flex flex-col jcc">
<div class=" min-w-100 m-auto p-auto">
</div>
<div class="m-0 p-0 w-100">
<?php
if(isset($_GET['showpart'])){
$partKeyword = $_GET['showpart'];
$selectPartName = "SELECT * FROM pcpartcomp WHERE pcPartID='$partKeyword'";
$check = mysqli_query($conn, $selectPartName);
WHILE($row = mysqli_fetch_array($check)){
$partName = $row['pcPartComponents'];
}
?>
<h1 align="left" style="font-size:30px;" class="text-black pl-2 pb-0.5 pt-2"><b><?php echo $partName?></b></h1>
<div class="b-1 text-white mr-3 ml-2"></div>
<div class="d-flex flex-wrap jcc responsive-container">
<?php
$showpart = "SELECT * FROM pcpart WHERE partKeyword='$partKeyword'";
$check = mysqli_query($conn, $showpart);
while($row = mysqli_fetch_array($check)){
$partID = $row['pcPartID'];
echo "
<div style='width:220px;' class='shadow-md responsive-card white b-rad-2 card-hover'>
<a style='color:#28AB87' class='text-deco-none' href='details.php?part_det=".$partID."'>
<div class='single-img'>
<img class='img2 mt-1' src='admin/upload/".$row['image']."'/>
</div>
<div style='font-size:20px;' class='text-center'>";
echo"<h4 class='m-1'>{$row['partTitle']}</h4></a><br>";
echo"<div class='text-primary'>
<b></b>
<div class='m-1 text-black'><b>₹{$row['price']}/-</b></div>
</div>
<div class='mx-sm'>
<div class='mb-3 mt-2 md-mt-2 d-flex jcsa md-flex-col'>
<div class='md-mb-2'><a style='background:#28AB87' class='button-field text-deco-none shadow-sm' href='details.php?part_det={$partID}'>Details</a></div>
<div><a style='background:#28AB87' class='button-field text-deco-none shadow-sm' href='index.php?add_cart={$partID}'>AddToCart</a></div>
</div>
</div>
</div>
</div>
";
}
}
?>
</div>
</div>
<div class="m-0 p-0 w-100">
<?php
if(isset($_GET['parts'])){
?>
<h1 align="left" style="font-size:30px;" class="text-black pl-2 pb-0.5 pt-2"><b>System Parts</b></h1>
<div class="b-1 text-white mr-3 ml-2"></div>
<div class="d-flex flex-wrap jcc responsive-container">
<?php
$query = "SELECT * FROM pcpart ORDER BY RAND() LIMIT 0,14;";
$check = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($check)) {
$partname = $row['partKeyword'];
$partID = $row['pcPartID'];
$discount = $row['price']*2;
echo "
<div style='width:250px;' class='d-flex responsive-card flex-col mx-sm mt-1 white p-sm b-rad-1 shadow-md '>
<div class='text-center single-img'>
<a style='color:#28AB87' class='text-deco-none transparent' href='details.php?part_det=".$partID."'>
<img width='200' height='200' src='admin/upload/".$row['image']."'/>
</a>
</div>
<div class='text-center p-1 ' >
<b><p style='color:gray;' class=''>{$row['partTitle']}</p></b>
<p style='font-size:18px;color:rgb(40,171,135)' class='my-sm'>₹{$row['price']} <strike class='pl-1'>₹{$discount}</strike></p>
<div class='d-flex jcc my-sm'>
<p style='font-size:16px;background:rgb(40,171,135);color:white' class='mr-sm px-1 py-sm b-rad-1 shadow-md'><a href='details.php?part_det={$partID}' class='text-deco-none text-white'>Details</a></p>
<p style='font-size:16px;background:rgb(40,171,135);color:white' class='mr-sm px-1 py-sm b-rad-1 shadow-md'><a class='text-deco-none text-white' href='index.php?add_cart={$partID}'>AddToCart</a></p>
</div>
</div>
</div>
";
}
header("LOCATION: index.php");
}
elseif(isset($_GET['complete'])){
?>
<h1 align="left" style="font-size:30px;" class="text-black px-3 pt-3 "><b>Completed Builds</b></h1>
<div class="b-1 text-white mr-3 ml-2"></div>
<div class="d-flex flex-wrap jcc">
<?php
$query = "SELECT * FROM pc_details ORDER BY RAND();";
$check = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($check)) {
$p_id = $row['pc_id'];
$discount = $row['pcPrice']*2;
echo "
<div style='width:250px;' class='d-flex responsive-card flex-col mx-sm mt-1 white p-sm b-rad-1 shadow-md'>
<a style='color:#28AB87' class='text-deco-none single-img' href='details.php?pc_det=".$p_id."'>
<img class='img2 mt-1' src='./admin/upload/".$row['pc_image']."'/>
</a>
<p style='color:gray;' class='mt-1'>{$row['pcName']}</p>
<p style='font-size:18px;color:rgb(40,171,135)' class='my-sm'>₹{$row['pcPrice']} <strike class='pl-1'>₹{$discount}</strike></p>
<div class='d-flex jcc my-1'>
<p style='font-size:16px;background:rgb(40,171,135);color:white' class='mr-sm px-1 py-sm b-rad-1'><a href='details.php?pc_det={$p_id}' class='text-deco-none text-white'>Details</a></p>
<p style='font-size:16px;background:rgb(40,171,135);color:white' class='mr-sm px-1 py-sm b-rad-1'><a class='text-deco-none text-white' href='index.php?addpc_cart={$p_id}'>Add to cart<a></p>
</div>
</div>"
;}
}
elseif(isset($_GET['secpart'])){
?>
<h1 align="left" style="font-size:30px;" class="text-black pl-2 pb-0.5 pt-2"><b>2nd Parts</b></h1>
<div class="b-1 text-white mr-3 ml-2"></div>
<div class="d-flex flex-wrap jcc responsive-container">
<?php
$query = "SELECT * FROM secndpart ORDER BY RAND() LIMIT 0,14;";
$check = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($check)) {
$partname = $row['partKeyword'];
$partID = $row['pcPartID'];
$discount = $row['price']*2;
echo "
<div style='width:250px;' class='d-flex responsive-card flex-col mx-sm mt-1 white p-sm b-rad-1 shadow-md '>
<div class='text-center single-img'>
<a style='color:#28AB87' class='text-deco-none transparent' href='details.php?part_det=".$partID."'>
<img width='200' height='200' src='./account/".$row['image']."'/>
</a>
</div>
<div class='text-center p-1 ' >
<b><p style='color:gray;' class=''>{$row['partTitle']}</p></b>
<p style='font-size:18px;color:rgb(40,171,135)' class='my-sm'>₹{$row['price']}</p>
<div class='d-flex jcc my-sm'>
<p style='font-size:16px;background:rgb(40,171,135);color:white' class='mr-sm px-1 py-sm b-rad-1 shadow-md'><a href='details.php?part_det={$partID}' class='text-deco-none text-white'>Details</a></p>
<p style='font-size:16px;background:rgb(40,171,135);color:white' class='mr-sm px-1 py-sm b-rad-1 shadow-md'><a class='text-deco-none text-white' href='index.php?add_cart={$partID}'>AddToCart</a></p>
</div>
</div>
</div>
";
}
header("LOCATION: index.php");
}
else{
?>
<h1 align="left" style="font-size:30px;" class="text-black pl-2 pb-0.5 pt-2"><b>System Parts</b></h1>
<div class="b-1 text-white mr-3 ml-2"></div>
<div class="d-flex flex-wrap jcc responsive-container">
<?php
$query = "SELECT * FROM pcpart ORDER BY RAND() ;";
$check = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($check)) {
$partname = $row['partKeyword'];
$partID = $row['pcPartID'];
echo "
<div style='width:270px;border:1px solid #D8D8D8' class='d-flex flex-col mx-sm mt-1 white p-sm b-rad-1 shadow-sm'>
<div class='text-center'>
<a style='color:#28AB87' class='text-deco-none transparent' href='details.php?part_det=".$partID."'>
<div class='single-img'>
<img width='200' height='200' src='admin/upload/".$row['image']."'/>
</div>
</a>
</div>
<div class='text-center p-1' >
<p style='color:gray;' class=''>{$row['partTitle']}</p>
<div class='m-1 text-black'><b>₹{$row['price']}/-</b></div>
<div class='mt-2'>
<div style='' class='d-flex jcsa'>
<div class='md-mb-2'><a style='background:#28AB87' class='button-field text-deco-none shadow-sm' href='details.php?part_det={$partID}'>Details</a></div>
<div><a style='background:#28AB87' class='button-field text-deco-none shadow-sm' href='index.php?add_cart={$partID}'>AddToCart</a></div>
</div>
</div>
</div>
</div>
";
}
?>
</div>
</div>
<div class="ml-1 mr-1 p-0 w-100">
<h1 align="left" style="font-size:30px;" class="text-black px-3 pt-3 "><b>Completed Builds</b></h1>
<div class="b-1 text-white mr-3 ml-2"></div>
<div class="d-flex flex-wrap jcc">
<?php
getCompleteBuilts();
}
?>
</div>
</div>
</div>
</div>
<!-- Content -->
<!-- <script>
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = 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(" active1", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active1";
}
</script> -->
<?php
require "footer.php";
?>
<?php
if (isset($_GET['add_cart'])) {
$userID = $_SESSION['userId'];
if($userID == 0){
echo "<script>window.open('login.php?login=notlogin','_self')</script>";
}
else{
$p_id = $_GET['add_cart'];
$check_product = "SELECT * FROM cart WHERE userID='$userID' AND productid='$p_id';";
$run_product = mysqli_query($conn, $check_product);
$part_qty = 1;
if (mysqli_fetch_array($run_product) > 0) {
echo"<script>alert('This product has already added in cart')</script>";
echo"<script>window.open('index.php','_self')</script>";
} else {
$query = "INSERT INTO cart(cID, userID, productid, quantity) VALUES (null, '$userID', '$p_id','$part_qty');";
$check = mysqli_query($conn, $query);
if($check){
echo"<script>window.open('index.php','_self')</script>";
}
}
}
}
if (isset($_GET['addpc_cart'])) {
$userID=$_SESSION['userId'];
$p_id = $_GET['addpc_cart'];
$check_product = "SELECT * FROM pccart WHERE userid='$userID' AND pcid='$p_id';";
$run_product = mysqli_query($conn, $check_product);
if (mysqli_fetch_array($run_product) > 0) {
echo"<script>alert('This product has already added in cart')</script>";
echo"<script>window.open('index.php?pro_id=$p_id','_self')</script>";
} else {
$query = "INSERT INTO pccart VALUES (null, '$p_id', '$userID');";
$check = mysqli_query($conn, $query);
if($check){
echo"<script>window.open('index.php?part_det='$p_id'','_self')</script>";
}
}
}
?>
<!-- <div style='width:220px;' class='shadow-md responsive-card white b-rad-2 card-hover'>
<a style='color:#28AB87' class='text-deco-none' href='details.php?part_det=".$partID."'>
<div class='single-img'>
<img class='img2 mt-1' src='admin/upload/".$row['image']."'/>
</div>
<div style='font-size:20px;' class='text-center'>";
echo"<h4 class='m-1'>{$row['partTitle']}</h4></a><br>";
echo"<div class='text-primary'>
<b></b>
<div class='m-1 text-black'><b>₹{$row['price']}/-</b></div>
</div>
<div class='mx-sm'>
<div class='mb-3 mt-2 md-mt-2 d-flex jcsa md-flex-col'>
<div class='md-mb-2'><a style='background:#28AB87' class='button-field text-deco-none shadow-sm' href='details.php?part_det={$partID}'>Details</a></div>
<div><a style='background:#28AB87' class='button-field text-deco-none shadow-sm' href='index.php?add_cart={$partID}'>AddToCart</a></div>
</div>
</div>
</div>
</div> -->