-
Notifications
You must be signed in to change notification settings - Fork 1
/
cart.php
43 lines (43 loc) · 1.37 KB
/
cart.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
<?php
session_start();
require_once("templates/common.php");
require_once("database/connection.php");
require_once("database/users.php");
require_once("database/restaurants.php");
if(!isset($_SESSION["username"]))
header("Location: login.php");
output_header("cart");
$db=getDatabaseConnection();
?>
<menu>
<h2>Shopping Cart</h2>
<?php $total = 0; ?>
<?php if(sizeof($_SESSION["dishes"])>0) {?>
<ul>
<?php foreach($_SESSION["dishes"] as $key => $dish){
if(!dish_exists($db,$dish)){
unset($_SESSION["dishes"][$key]);
continue;
}
?>
<?php $dish_price = getDishName($db,$dish)["price"]."€"?>
<?php $total += $dish_price ?>
<li class="dish <?=$dish?>">
<a><p><?=getDishName($db,$dish)["name"]?>:<?=" ".$dish_price?></p></a>
</li>
<?php } ?>
</ul>
<?php }?>
<?php if(sizeof($_SESSION["dishes"])==0){?>
<p id="empty_cart"> Your cart is empty! </p>
<?php }?>
<p id="total">Total: <?=$total?> €</p>
<form action="action_create_request.php" method="post">
<input type="hidden" name="csrf" value="<?=$_SESSION['csrf']?>">
<?php if(sizeof($_SESSION["dishes"])>0){?>
<button id="Checkout" type="submit">
Checkout
</button>
<?php } ?>
</form>
</menu>