-
Notifications
You must be signed in to change notification settings - Fork 0
/
form-view.php
111 lines (99 loc) · 4.46 KB
/
form-view.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
<?php // This files is mostly containing things for your view / html
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<title>Play & Gear</title>
</head>
<body>
<div class="container">
<h1>Place your order</h1>
<?php // Navigation trhough products url usoing GET. then switch this also in index
?>
<!-- To show html add echo with '' quotes -->
<?php echo '
<nav>
<ul class="nav">
<li class="nav-item">
<a class="nav-link ' . ($order == 'gear' ? 'btn btn-info' : "") .' " href="index.php?order=gear">Video Gears</a>
</li>
<li class="nav-item">
<a class="nav-link ' . ($order == 'play' ? 'btn btn-info' : "") .' " href="index.php?order=play">Play Gears</a>
</li>
</ul>
</nav>
'
?>
<!-- show chosen products and delivery address -->
<!-- display message that the purchase is successful-->
<?php if (!empty($result['message'])) { ?>
<div class="alert <?php if ($result['errors']) {
echo 'alert-danger';
} else {
echo 'alert-success';
} ?>">
<?= $result['message'] ?>
</div>
<?php }; ?>
<form method="post" action=''>
<div class="form-row">
<div class="form-group col-md-6">
<label for="email">E-mail:</label>
<input type="email" id="email" name="email" class="form-control" value="<?php echo $_SESSION['email'] ?? '' ?>"/>
</div>
<div></div>
</div>
<fieldset>
<legend>Address</legend>
<div class="form-row">
<div class="form-group col-md-6">
<label for="street">Street:</label>
<input type="text" name="street" id="street" class="form-control" value="<?php echo $_SESSION['street'] ?? '' ?>">
</div>
<div class="form-group col-md-6">
<label for="streetnumber">Street number:</label>
<input type="text" id="streetnumber" name="streetnumber" class="form-control" value="<?php echo $_SESSION['streetnumber'] ?? '' ?>">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="city">City:</label>
<input type="text" id="city" name="city" class="form-control" value="<?php echo $_SESSION['city'] ?? '' ?>">
</div>
<div class="form-group col-md-6">
<label for="zipcode">Zipcode</label>
<input type="text" id="zipcode" name="zipcode" class="form-control" value="<?php echo $_SESSION['zipcode'] ?? '' ?>">
</div>
</div>
</fieldset>
<fieldset>
<legend>Products</legend>
<!-- if video gears clicked, then show $gears, etc. change $products into $$order -->
<?php foreach ( ${$order} as $i => $product) : ?>
<label>
<?php // <?p= is equal to <?php echo
?>
<input type="checkbox" value="1"
name="products[<?php echo $i ?>]"
<?php echo isset($_POST['products'][$i]) ? 'checked ':''; ?>
/>
<?php echo $product['name'] ?> - € <?= number_format($product['price'], 2) ?>
</label>
<br />
<?php endforeach; ?>
</fieldset>
<button type="submit" class="btn btn-primary" name='order'>Order!</button>
</form>
<footer>You already ordered <strong>€ <?php echo $totalValue ?></strong> in food and drinks.</footer>
</div>
<style>
footer {
text-align: center;
}
</style>
</body>
</html>