-
Notifications
You must be signed in to change notification settings - Fork 0
/
product.php
38 lines (34 loc) · 1.2 KB
/
product.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
<?php
if (isset($_GET['id'])) {
$stmt = $pdo->prepare('SELECT * FROM products WHERE id = ?');
$stmt->execute([$_GET['id']]);
$product = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$product) {
exit('Product does not exist!');
}
} else {
exit('Product does not exist!');
}
?>
<?=template_header('Product')?>
<div class="product content-wrapper">
<img src="imgs/<?=$product['img']?>" width="500" height="500" alt="<?=$product['name']?>">
<div>
<h1 class="name"><?=$product['name']?></h1>
<span class="price">
<?=$product['price']?>
<?php if ($product['old_price'] > 0): ?>
<span class="rrp"><?=$product['old_price']?></span>
<?php endif; ?>
</span>
<form action="index.php?page=cart" method="post">
<input type="number" name="quantity" value="1" min="1" max="<?=$product['quantity']?>" placeholder="Quantity" required>
<input type="hidden" name="product_id" value="<?=$product['id']?>">
<input type="submit" value="Add To Cart">
</form>
<div class="description">
<?=$product['desc']?>
</div>
</div>
</div>
<?=template_footer()?>