Code producing error message and I can't figure out why
Posted: Mon Jun 14, 2010 1:56 pm
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>Product Cost</title>
</head>
<body>
<?php // Script 4.5 - handle_calc.php
/*This script takes values from calculator.html and performs
total cost and monthly payment calculations. */
// Address error handling.
ini_set ('display_errors', 1);
error_reporting(E_ALL & ~E_NOTICE);
// In case register_globals is enabled.
$price = $_POST['price'];
$quantity = $_POST['quantity'];
$discount = $_POST['discount'];
$tax = $_POST['tax'];
$shipping = $_POST['shipping'];
$payments = $_POST['payments'];
// Calculate the total
$total=(($price * $quantity) + $shipping) - $discount;
// Determine the tax rate
$taxrate = $tax/100;
$taxrate++;
// Factor in the tax rate.
$total = $total * $taxrate;
// Calculate the monthly payments.
$monthly = $total / $payments;
// Apply the proper formatting.
$total = number_format ($total, 2);
$monthly = number_format ($monthly, 2);
// Print out the results.
print "You have selected to purchase:<br />
<b>$quantity</b> widget(s) at <br />
$<b>$price</b> price with a <br />
$<b>$shipping</b> shipping cost and a <br />
<b>$tax</b> percent tax rate. <br />
After your $<b>$discount</b> discount, the total cost is
$<b>$total</b>.<br />
Divided over <b>$payments</b> monthly payments, that would be $<b>$monthly</b> each.";
?>
</body>
</html>