1.	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2.		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3.	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4.	<head>
5.		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6.		<title>Product Cost Calculator</title>
7.		<style type="text/css" media="screen">
8.			.number { font-weight: bold;}
9.		</style>
10.	</head>
11.	<body>
12.	<?php // Script 4.3 - handle_calc.php #4
13.	/* This script takes values from calculator.html and performs 
14.	total cost and monthly payment calculations. */
15.	
16.	// Address error handling, if you want.
17.	
18.	// Get the values from the $_POST array:
19.	$price = $_POST['price'];
20.	$quantity = $_POST['quantity'];
21.	$discount = $_POST['discount'];
22.	$tax = $_POST['tax'];
23.	$shipping = $_POST['shipping'];
24.	$payments = $_POST['payments'];
25.	
26.	// Calculate the total:
27.	$total = (($price * $quantity) + $shipping) - $discount;
28.	
29.	// Determine the tax rate:
30.	$taxrate = $tax/100;
31.	$taxrate++;
32.	
33.	// Factor in the tax rate:
34.	$total = $total * $taxrate;
35.	
36.	// Calculate the monthly payments:
37.	$monthly = $total / $payments;
38.	
39.	// Apply the proper formatting.
40.	$total = number_format ($total, 2);
41.	$monthly = number_format ($monthly, 2);
42.	
43.	// Print out the results:
44.	print "<div>You have selected to purchase:<br />
45.	<span class=\"number\">$quantity</span> widget(s) at <br />
46.	$<span class=\"number\">$price</span> price each plus a <br />
47.	$<span class=\"number\">$shipping</span> shipping cost and a <br />
48.	<span class=\"number\">$tax</span> percent tax rate.<br />
49.	After your $<span class=\"number\">$discount</span> discount, the total cost is 
50.	$<span class=\"number\">$total</span>.<br />
51.	Divided over <span class=\"number\">$payments</span> monthly payments, that would be $<span class=\"number\">$monthly</span> each.</p></div>";
52.	
53.	?>
54.	</body>
55.	</html>