2DWorlds Forums
PHP Tax Calculator: Oppinions? - Printable Version

+- 2DWorlds Forums (http://2dworlds.buildism.net/forum)
+-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4)
+--- Forum: Scripting (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=13)
+--- Thread: PHP Tax Calculator: Oppinions? (/showthread.php?tid=4511)



PHP Tax Calculator: Oppinions? - Chaos - 05-10-2011

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>



RE: PHP Tax Calculator: Oppinions? - Ashely - 05-10-2011

Wow, impressive.


RE: PHP Tax Calculator: Oppinions? - Jacob__mybb_import1 - 05-10-2011

Good job! You can do some really cool things with PHP.


RE: PHP Tax Calculator: Oppinions? - toast - 05-10-2011

Opinion? This seems like it should be client side
But it's great, I know like, extremely minimal PHP (like echo and how to run mysql)


RE: PHP Tax Calculator: Oppinions? - Chaos - 05-10-2011

I tend to use the print function. Echo confuses me...