<html>
<head>
    <title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
// create short variable names
$tireqty  = $_POST['tireqty'];
$oilqty   = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
$find     = $_POST['find'];


echo '<p>Your order is as follows:</p>';
if ($tireqty ==0) {
    echo "You did not order anything on the previous page!<br />";
} 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 "<br /><br />";

$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo "Items ordered: " . $totalqty. "<br ./>";

define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);

$totalamount = $tireqty * TIREPRICE
   + $oilqty * OILPRICE
   + $sparkqty * SPARKPRICE;

echo "Subtotal:    $".number_format($totalamount,2)."<br />";
$taxrate = 0.10;
$totalamount = $totalamount * (1+ $taxrate);
echo "Total     Including     Tax:
$".number_format($totalamount, 2)."<br />";

/*echo "<p>this is the $_POST[find] variable: " . var_dump($_POST['find']) . "</p>";
echo "<p>this is the \"find\" variable: " . var_dump($find) . "</p>";*/

echo  '<p>This is what\'s in the $find variable: ' . $find . '</p>';

if ($find == "a") {
    echo "<p>Regular customer.</p>";
} elseif ($find == "b") {
    echo "<p>Customer referred by TV advert";
} elseif ($find == "c") {
    echo "<p>Customer referred by phone directory</p>";
 } elseif ($find == "d") {
    echo "<p>Customer referred by word of mount</p>";
} else {
    echo "<p>We do not know how this customer found us.</p>";
}
?>
</body>
</html>
