PHP Code


$theCost=$_POST['cost'];
function CalcTax($theCost)
{
return $theCost*.05;
}
$theTax=CalcTax($theCost);
$subtotal=$theCost + $theTax;
function CalcShip($subtotal) {
if ($subtotal <= 25)
{
return 3.00;
}
elseif ($subtotal > 25 && $subtotal <= 50)
{
return 4.00;
}
elseif ($subtotal > 50 && $subtotal <= 75)
{
return 5.00;
}
elseif ($subtotal > 75)
{
return 6.00;
}
else
{
print "$cost is not a valid cost.";
return 0;
}
}
$theShip=CalcShip($subtotal);
$total_cost=$theCost + $theTax + $theShip;
print "
Your cost = $theCost";
print "
Your tax = $theTax";
print "
Your shipping = $theShip";
print "
Your total cost = $total_cost";