PHP Tax Calculator: Oppinions?
#1
handle_calc.php:

<html>
<title>Product Cost Calculator</title>
<style type="text/css" media="screen">
.number { font-weight: bold;}
</style>
</head>

<body>
<?php // Handle_calc.php

//get the values from the $_POST array
ini_set ('display_errors', 1);
$price = $_POST ['price'];
$quantity = $_POST ['quantity'];
$discount = $_POST ['discount'];
$tax = $_POST ['tax'];
$shipping = $_POST ['shipping'];
$payments = $_POST ['payments'];

//Calculate total cost
$total = (($price * $quantity) + $shipping) - $discount;

//calculate tax rate
$taxrate = $tax/100;
$taxrate = $taxrate + 1;

//factor in taxrate
$taxrate = ($tax/100) + 1;

//calculate monthly payments
$monthly = $total / $payments;

//supply proper formatting
$total = number_format ($total, 2);
$monthly = number_format ($monthly, 2);

//print out the results
print "<div>You have selected to purchase:<br />
<span class=\"number\">$quantity</span> widget(s) at <br />
$<span class=\"number"\">$price</span> price each plus a <br />
$<span class=\"number"\">$shipping</span> shipping cost and a <br />
$<span class=\"number"\">$tax</span> percent tax rate.<br />
After your $<span class=\"number"\">$discount</span> discount, the total cost is
$<span class=\"number"\">$total</span>.<br />
Divided over <span class=\"number"\">$payments</span> monthly payments, that would be
$<span class=\"number"\">$monthly</span> each.</p></div>";

?>
</body>
</html>

handle_form.php:

<html>
<body>
<?php //handel_form for feedback

//This page recieves the data from feedback.html
//it will recieve: title, name, and submit in $_POST.

ini_set ('display_errors', 1);

$title = $_POST['title'];
$name = $_POST ['name'];
$response = $_POST ['response'];
$comments = $_POST ['comments'];

<p>Thanks, $title $name for your comments.</p>
<p>you stated that you found this example to be '$response' and added: <br />$comments<p>

?>
</body>
</html>
[Image: chaosthegreat.png]
Reply


Messages In This Thread
PHP Tax Calculator: Oppinions? - by Chaos - 05-10-2011, 12:48 AM

Forum Jump:


Users browsing this thread: 3 Guest(s)