-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.php
More file actions
73 lines (60 loc) · 1.93 KB
/
process.php
File metadata and controls
73 lines (60 loc) · 1.93 KB
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
<!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://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<title>Ice Cream Shoppe</title>
</head>
<body>
<h1>Thank your for your order!</h1>
<?php
//turn on error reporting
ini_set('display_errors', 1);
error_reporting(E_ALL);
define('PRICE_PER_SCOOP', 2.50);
define('SALES_TAX_RATE', 0.11);
//For testing
echo "<pre";
var_dump($_POST);
echo "</pre>";
//get data from post array
if (!empty($_POST['scoops'])){
$scoops = $_POST['scoops'];
}
else{
echo "<p> Enter scoops!</p>";
return;
}
//dont think this is right
if (!isset($_POST['flavor'])){
$flavors = $_POST['flavor'];
}
else{
echo "<p>Please select at least one flavor</p>";
return;
}
if (!isset($_POST['cone'])){
$cone = $_POST['cone'];
}
else{
echo "<p>Please select a cone or cup</p>";
return;
}
$flavorString = implode(",", $flavors);
//Calculate total due
$subtotal = PRICE_PER_SCOOP * $scoops;
$tax = $subtotal * SALES_TAX_RATE;
$total = $subtotal + $tax;
//Print a summary
echo "<p>$scoops scoops</p>";
echo "<p>Flavors: $flavorString</p>";
echo "<p>Cone: $cone</p>";
echo "<p>Subtotal: $subtotal</p>";
echo "<p>Tax: $tax</p>";
echo "<p>Total: $total</p>";
?>
</body>
</html>