-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheckout.php
64 lines (64 loc) · 1.79 KB
/
checkout.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
<?php
session_start();
require_once "./functions/database_functions.php";
$title = "Checking out";
require "./template/header.php";
if(!isset($_SESSION['user']))
{
echo '<div class="alert alert-danger" role="alert">
You Need to <a href="Signin.php">Signin</a> First!
</div>';
}
else if(isset($_SESSION['cart']) && (array_count_values($_SESSION['cart'])))
{
?>
<table class="table">
<tr>
<th>Item</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
</tr>
<?php
foreach($_SESSION['cart'] as $serial => $qty)
{
$conn = db_connect();
$med = mysqli_fetch_assoc(getmedByserial($conn, $serial));
?>
<tr>
<td><?php echo $med['med_name'] . " by " . $med['med_manufacturer']; ?></td>
<td><?php echo "Rs " . $med['med_price']; ?></td>
<td><?php echo $qty; ?></td>
<td><?php echo "Rs" . $qty * $med['med_price']; ?></td>
</tr>
<?php } ?>
<tr>
<th> </th>
<th> </th>
<th><?php echo $_SESSION['total_items']; ?></th>
<th><?php echo "Rs " . $_SESSION['total_price']; ?></th>
</tr>
</table>
<?php
if(isset($_SESSION['user']))
{
echo '
<form method="post" action="purchase.php" class="form-horizontal">
<div class="form-group" style="margin-left:0px">
<input type="submit" name="submit" value="Purchase" class="btn btn-primary" >
<a href="cart.php" class="btn btn-primary">Edit Cart</a>
</div>
</form>
<p class="lead">Please press Purchase to confirm your purchase, or Edit Cart to add or remove items.</p>';
}
}
else
{
echo "<h3 class=\"text-warning\">Your cart is empty! Please make sure you add some medicines in it!</h3>";
}
if(isset($conn))
{
mysqli_close($conn);
}
require_once "./template/footer.php";
?>