forked from fazrigading/playstation-game-store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetailpage.php
164 lines (152 loc) · 5.27 KB
/
detailpage.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
<?php
session_start();
require 'config.php';
$id = $_GET["id"];
$product = query("SELECT * FROM products WHERE id = $id")[0];
if (isset($_POST['btnCart']) || isset($_POST['btnBuy'])) {
if (!isset($_SESSION['loginUser'])) {
header('Location: auth.php');
exit;
}
}
if (isset($_POST['btnCart'])) {
$query = "SELECT id FROM cart WHERE id_user = $_COOKIE[id] AND id_product = $id";
$isExist = query($query);
if ($isExist) {
echo "
<script>
alert('Berhasil memasukkan ke keranjang!');
</script>";
} else {
if (addToCart($_POST) > 0) {
echo "
<script>
alert('Berhasil memasukkan ke keranjang!');
</script>";
} else {
echo "<script>
alert('Gagal memasukkan ke keranjang!');
</script>";
}
}
}
if (isset($_POST['btnBuy'])) {
if (buy($_POST) > 0) {
header('Location: payment/success.php');
} else {
echo "<script>
alert('Gagal membeli barang!');
</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="resources/css/detailpage.css">
<link rel="stylesheet" href="resources/css/catalog.css">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;700;900&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/5bbbb39d34.js" crossorigin="anonymous"></script>
<title><?= $product["category"] ?></title>
</head>
<body>
<div class="container">
<!-- NAVBAR -->
<div class="navbar">
<a href="index.php"><img src="./resources/assets/logo.png" class="logo"></a>
<nav>
<ul id="menuList">
<li><a href="index.php">Home</a></li>
<li><a href="aboutus.php">About Us</a></li>
<li><a href="catalog.php">Catalog</a></li>
<?php
if (isset($_SESSION["loginAdmin"])) {
echo "<li><a href='admin/products/'>Dashboard</a></li>";
} else if (!isset($_SESSION["loginUser"]) && !isset($_SESSION["loginAdmin"])) {
echo "<li><a href='auth.php'>Login</a></li>";
}
if (isset($_SESSION["loginUser"]) || isset($_SESSION["loginAdmin"])) {
echo "<li><a href='payment/'>Cart</a></li>";
echo "<li><a href='riwayat.php'>History</a></li>";
echo "<li><a href='profile.php'>Profile</a></li>";
echo "<li><a href='logout.php'>Logout</a></li>";
}
?>
<li>
<label>
<input type="checkbox" class="checkbox" id="modegelap3">
<span class="check"></span>
</label>
</li>
</ul>
</nav>
</div>
<main>
<div class="main-container">
<div class="image-container">
<img src="./resources/img/<?= $product["photo"] ?>" height="500px" alt="">
</div>
<!-- <div class = "side-image-container">
<div class = "side-image">
<img src="resources/assets/PS5SIDE.jpg" alt="">
</div>
<div class = "side-image">
<img src="resources/assets/PS5SIDE2.jpg" alt="">
</div>
<div class = "side-image">
<img src="resources/assets/PS5SIDE3.jpg" alt="">
</div>
</div> -->
</div>
<br>
<div class="product">
<div class="product-detail">
<h5>
<?= $product["category"] ?>
</h5>
<h2>
<?= $product["name"] ?>
</h2>
<br>
<span class="product-price">
Rp.<?= number_format($product['price'], 2, ',', '.') ?>
</span>
<br><br>
<ul>
<li>Stock: <?= $product["stock"] ?></li>
<li><?= $product["descriptions"] ?></li>
</ul>
</div>
<div class="product-button">
<form action="" method="post">
<input type="hidden" name="productName" value="<?= $product["name"] ?>">
<input type="hidden" name="idProduct" value="<?= $product["id"] ?>">
<input type="hidden" name="totalPrice" value="<?= $product["price"] ?>">
<!-- TOMBOL TAMBAH KE KERANJANG -->
<button type="submit" name="btnCart" id="add-cart">Tambah Ke Keranjang</button><br>
<!-- TOMBOL BELI SEKARANG -->
<button type="submit" name="btnBuy" id="buy-now">Beli Sekarang</button><br>
</form>
</div>
</div>
</main>
<script src="resources/js/detailpage.js"></script>
<footer>
<div class="footer-content">
<h2>Playstation Game Store</h2>
<p>This website created by:</p>
<p>Fazri Gading (2009106031), Alexander Januar (2009106035), dan Risky Kurniawan (2009106050).</p>
<p>Click Github icon below to check our repository.</p>
<ul class="socials">
<li><a href="https://github.com/fazrigading/playstation-game-store/" target="_blank"><i class="fa fa-github"></i></a></li>
</ul>
</div>
<div class="footer-bottom">
<p>Copyright © 2022 Rigalex</p>
</div>
</footer>
</body>
</html>