Advertisement
Guest User

Untitled

a guest
May 21st, 2012
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.66 KB | None | 0 0
  1. <?php
  2.   // create short variable names
  3.   $tireqty = $_POST['tireqty'];
  4.   $oilqty = $_POST['oilqty'];
  5.   $sparkqty = $_POST['sparkqty'];
  6.   $find = $_POST['find'];
  7. ?>
  8. <html>
  9. <head>
  10.   <title>Bob's Auto Parts - Order Results</title>
  11. </head>
  12. <body>
  13. <h1>Bob's Auto Parts</h1>
  14. <h2>Order Results</h2>
  15. <?php
  16.  
  17.     echo "<p>Order processed at ".date('H:i, jS F Y')."</p>";
  18.  
  19.     echo "<p>Your order is as follows: </p>";
  20.  
  21.     $totalqty = 0;
  22.     $totalqty = $tireqty + $oilqty + $sparkqty;
  23.     echo "Items ordered: ".$totalqty."<br />";
  24.  
  25.  
  26.     if ($totalqty == 0) {
  27.  
  28.       echo "You did not order anything on the previous page!<br />";
  29.  
  30.     } else {
  31.  
  32.       if ($tireqty > 0) {
  33.         echo $tireqty." tires<br />";
  34.       }
  35.  
  36.       if ($oilqty > 0) {
  37.         echo $oilqty." bottles of oil<br />";
  38.       }
  39.  
  40.       if ($sparkqty > 0) {
  41.         echo $sparkqty." spark plugs<br />";
  42.       }
  43.     }
  44.  
  45.  
  46.     $totalamount = 0.00;
  47.  
  48.     define('TIREPRICE', 100);
  49.     define('OILPRICE', 10);
  50.     define('SPARKPRICE', 4);
  51.  
  52.     $totalamount = $tireqty * TIREPRICE
  53.                  + $oilqty * OILPRICE
  54.                  + $sparkqty * SPARKPRICE;
  55.  
  56.     echo "Subtotal: $".number_format($totalamount,2)."<br />";
  57.  
  58.     $taxrate = 0.10;  // local sales tax is 10%
  59.     $totalamount = $totalamount * (1 + $taxrate);
  60.     echo "Total including tax: $".number_format($totalamount,2)."<br />";
  61.  
  62.     if($find == "a") {
  63.       echo "<p>Regular customer.</p>";
  64.     } elseif($find == "b") {
  65.       echo "<p>Customer referred by TV advert.</p>";
  66.     } elseif($find == "c") {
  67.       echo "<p>Customer referred by phone directory.</p>";
  68.     } elseif($find == "d") {
  69.       echo "<p>Customer referred by word of mouth.</p>";
  70.     } else {
  71.       echo "<p>We do not know how this customer found us.</p>";
  72.     }
  73.  
  74. ?>
  75. </body>
  76. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement