-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessororder.php
73 lines (62 loc) · 1.56 KB
/
processororder.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
<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
$find = $_POST['find'];
echo '<p>Order processed at ';
echo date('H:i, jS F Y');
echo "</p>";
echo "<p> Your order is as follows: </p> ";
$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
if ($totalqty == 0) {
echo '<p style="color:red">';
echo 'You did not order anything on the previous page!';
echo '</p>';
} else {
if ($tireqty > 0)
echo $tireqty.' tires<br/>';
if ($oilqty > 0)
echo $oilqty. ' bottles of oil<br/>';
if ($sparkqty > 0)
echo $sparkqty. ' spark plugs<br/>';
}
echo "Items ordered: ".$totalqty."<br/>";
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;
echo "Subtotal: $".number_format($totalamount,3)."<br/>";
$taxrate = 0.10;
$totalamount = $totalamount * (1 + $taxrate);
echo "Total including tax: $".number_format($totalamount, 2)."<br/>";
switch ($find) {
case "a":
echo "<p>Regular customer.</p>";
break;
case "b":
echo "<p>Customer referred by TV advert.</p>";
break;
case "c":
echo "<p>Customer referred by phone directory.</p>";
break;
case "d":
echo "<p>Customer referred by word of mouth.</p>";
break;
default:
echo "<p>We do not know how this customer found us.</p>";
break;
}
?>
</body>
</html>