Hello there
I am trying to run my first piece of php code (well second) but i seem to get the php code output on the browser so i would like some advice on where i am going wrong.
Here is the code for the first form which is Orderform.html
this is the code for the php page called processingorder.php
I have just installed XAMPP and all services are running, I have managed to run a simpler php form but this one just seems to display the code after you try to enter any values or even leave null values like this:
Todd's Auto Parts
Order Results
"; echo $oilqty." bottles of oil
"; echo $sparkplugqty." spark plugs
"; $totalqty = 0; $totalamount = 0.00; define("TIREPRICE", 100); define("OILPRICE", 10); define("SPARKPLUGPRICE", 4); $totalqty = $tireqty + $oilqty + $sparkplugqty; $totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkplugqty * SPARKPLUGPRICE; $totalamount = number_format($totalamount, 2); echo "
\n"; echo "Items ordered: ".$totalqty."
\n; echo "Subtotal: ".$totalamount."
"\n; $taxrate = 0.10; // local sales tax is 10% here $totalamount = $totalamount * (1+$taxrate); $totalamount = number_format($totalamount, 2); echo "total Including Tax: $".$totalamount."
\n"; ?>
I am trying to run my first piece of php code (well second) but i seem to get the php code output on the browser so i would like some advice on where i am going wrong.
Here is the code for the first form which is Orderform.html
</head> <body> <h1>Todd's Auto Parts</h1> <h2>Order Form</h2> <form action="processingorder.php" method=post> <table border=0> <tr bgcolor=#cccccc> <td width=150>Item</td> <td width=15>Quantity</td> </tr> <tr> <td>Tires</td> <td align=center><input type="text" name="tireqty" size=3 maxlength=3></td> </tr> <tr> <td>Oil</td> <td align=center><input type="text" name="oilqty" size=3 maxlength=3></td> </tr> <tr> <td>Spark Plugs</td> <td align=center><input type="text" name="sparkplugqty" size=3 maxlength=3></td> </tr> <tr> <td colspan=2 align=center><input type=submit value="Submit Order"></td> </tr> </table> </form> </body> </html>
this is the code for the php page called processingorder.php
<html>
<head><title>Todd's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?
echo "<P>Order Processed.";
echo date("H:i, jS F");
echo "<br>";
echo $tireqty." tires<BR>";
echo $oilqty." bottles of oil<BR>";
echo $sparkplugqty." spark plugs<BR>";
$totalqty = 0;
$totalamount = 0.00;
define("TIREPRICE", 100);
define("OILPRICE", 10);
define("SPARKPLUGPRICE", 4);
$totalqty = $tireqty + $oilqty + $sparkplugqty;
$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkplugqty * SPARKPLUGPRICE;
$totalamount = number_format($totalamount, 2);
echo "<BR>\n";
echo "Items ordered: ".$totalqty."<br>\n;
echo "Subtotal: ".$totalamount."<BR>"\n;
$taxrate = 0.10; // local sales tax is 10% here
$totalamount = $totalamount * (1+$taxrate);
$totalamount = number_format($totalamount, 2);
echo "total Including Tax: $".$totalamount."<BR>\n";
?>
</body>
</html>
I have just installed XAMPP and all services are running, I have managed to run a simpler php form but this one just seems to display the code after you try to enter any values or even leave null values like this:
Todd's Auto Parts
Order Results
"; echo $oilqty." bottles of oil
"; echo $sparkplugqty." spark plugs
"; $totalqty = 0; $totalamount = 0.00; define("TIREPRICE", 100); define("OILPRICE", 10); define("SPARKPLUGPRICE", 4); $totalqty = $tireqty + $oilqty + $sparkplugqty; $totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkplugqty * SPARKPLUGPRICE; $totalamount = number_format($totalamount, 2); echo "
\n"; echo "Items ordered: ".$totalqty."
\n; echo "Subtotal: ".$totalamount."
"\n; $taxrate = 0.10; // local sales tax is 10% here $totalamount = $totalamount * (1+$taxrate); $totalamount = number_format($totalamount, 2); echo "total Including Tax: $".$totalamount."
\n"; ?>