-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmens.php
98 lines (86 loc) · 3.26 KB
/
mens.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
<?php
session_start();
error_reporting(E_ALL);
include('config.php');
$msg = '';
if (isset($_GET['add'])) {
if (isset($_SESSION['user'])) {
$productid = $_GET['add'];
$user = $_SESSION['user'];
$sql = "INSERT INTO cart(productid,user) VALUES(:productid,:user)";
$query = $db->prepare($sql);
$query->bindParam(':productid', $productid, PDO::PARAM_STR);
$query->bindParam(':user', $user, PDO::PARAM_STR);
$query->execute();
$lastInsertId = $db->lastInsertId();
if ($lastInsertId) {
$msg = '<div id="msg" class="alert alert-success"><strong>Product Added To Cart</strong></div>';
} else {
$msg = '<div id="msg" class="alert alert-danger"><strong>Unable To Add</strong></div>';
}
} else {
$msg = '<div id="msg" class="alert alert-danger"><strong>Please Login</strong></div>';
}
} else {
}
// FECTH PRODUCTS
$sql = "SELECT * from products WHERE category = 'Mens'";
$query = $db->prepare($sql);
$query->execute();
$results = $query->fetchAll(PDO::FETCH_OBJ);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TrendZ | Online Store for Latest Trends</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="./css/style.css">
<script>
if (typeof window.history.pushState == 'function') {
window.history.pushState({}, "Hide", '<?php echo $_SERVER['PHP_SELF']; ?>');
}
</script>
</head>
<body>
<section>
<?php include('./inc/header.php'); ?>
<div class="container mt-5 my-section">
<h3 class="py-4">Mens</h3>
<div class="msg"><?php echo $msg; ?></div>
<div class="row">
<?php
if ($query->rowCount() > 0) {
foreach ($results as $result) { ?>
<div class="col-lg-3 col-md-6 mb-4">
<div class="card h-100">
<a href="#"><img class="card-img-top" src="./img/products/<?php echo $result->img; ?>" alt="<?php echo $result->title; ?>" title="<?php echo $result->title; ?>"></a>
<div class="card-body">
<h4 class="card-title">
<a href="#"><?php echo $result->title; ?></a>
</h4>
<h5><?php echo CURRENCY ?> <?php echo $result->price; ?></h5>
<a href="mens.php?add=<?php echo $result->id; ?>" class="btn btn-dark mt-2">Add To Cart</a>
</div>
</div>
</div>
<?php }
} ?>
</div>
</div>
<?php include('./inc/footer.php'); ?>
</section>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
setTimeout(function() {
$('#msg').slideUp("slow");
}, 2000);
});
</script>
</body>
</html>