today i was writing a script for a shopping cart and ofcourse, i need to figure out how to show the sales tax for a price, so i came up with this simple easy to use script you can use for your website if you need to find out how you can get the tax for your state for example.

here is the script: just copy and paste into a text editor like notepad and save it as webune-tax.php then upload to your wesbite and open it with your broswer and see it in action.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Sales Tax Function</title>
</head>

<body>

<p>This Function Script Created By Webune.com</p>
<p><img src="http://www.webune.com/images/headers/default_logo.jpg"></p>
<form name="form1" method="post" action="">

Price:<br>
<input type="text" name="price" value="<?php echo $_POST['price']; ?>">
(example: 49.00) <br>

<br>
Enter Sales Rate:<br>
<input type="text" name="tax_rate" value="<?php echo $_POST['tax_rate']; ?>">
(example: 8.25) <br>

<br>
<input type="submit" name="Submit" value="Submit">
</form>
<hr width="200" align="left">

<?php
$Subtotal = $_POST['price'];
$Tax = round( (($_POST['price'] * $_POST['tax_rate']) / 100 ), 2);
$Total = ($Tax + $Subtotal);
?>
Subtotal: $<?php echo $Subtotal; ?><br>
Tax : $<?php echo $Tax; ?><br>
Total: $<?php echo $Total; ?><br>

<p align="center"><a href="http://www.webune.com">More Free PHP Scripts &gt;&gt;</a> </p>

</body>
</html>