aboutsummaryrefslogtreecommitdiff
path: root/public/product.php
blob: 18cc9361c49a9a04c2aef6cabed053a12ba31fc4 (plain)
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
<!DOCTYPE html>
<?php require "../lib/db.php"; ?>
<?php
function refuse() {
	http_response_code(404);
	die();
}

$statement = $cursor->prepare("select id, image, price, name, description from webs.product where id = ?");
$statement->bind_param("i", $_GET['id']);
if (!$statement->execute()) refuse();
$res = $statement->get_result();
if (!mysqli_num_rows($res)) refuse();
$product = $res->fetch_object();
?>
<html>
<head>
	<?php include 'head.php' ?>
	<title>dit is product</title>
	<link rel='stylesheet' type='text/css' media='screen' href='product.css'>
</head>
<body>
	<?php include 'navbar.php' ?>
	<div class="main limwidth">
		<div class="twocolumn">
			<div class="column left">
				<?php
					$img = "/img/product/".$product->id."-full.jpg";
					echo <<<"EOF"
						<a href="$img" target="_blank">
							<img src="$img" alt="$product->name">
						</a>
					EOF;
				?>
			</div>
			<div class="column right">
				<h2><?php echo $product->name ?></h2>
				<span class="price"><?php echo $product->price ?></span>
				<p class="info"><?php echo $product->description ?></p>
				<form action="/cart.php" method="post">
					<input type="hidden" name="type" value="add">
					<input type="hidden" name="product_id" value="<?php echo $product->id ?>">
					<input type="submit" class="button filled" value="Toevoegen aan winkelwagen">
				</form>
			</div>
		</div>
	</div>
	<?php include 'footer.php' ?>
</body>
</html>