Tax Calculator Problem
Posted: Sun Aug 17, 2008 6:06 pm
Hi,
I'm just starting PHP, and have an old textbook with a simple tax calculator problem...
I have typed the code in as instructed, but cannot get the desired result...
I believe the book's example does not include varible declarations...
I have no idea what the SecondTime variable is for...
PLEASE HELP!!!
Here is my code...
-----------------------------------------------------------------------------------------------------------------------
<html>
<head>
<title> Sales Tax Calculator </title>
</head>
<?
if ($SecondTime == "")
{
echo "
<body><h1> Please enter amount and tax rate </h1>
<br>
<br>
<form action = \"taxcalc.php\" method = \"post\">
<input type = \"hidden\" name = \"SecondTime\" Value = 1>
Amount
<input type = text name\"amount\" size = 15><br><br>
Tax Rate:
<Input type = text name = \"rate\" size = 15><br><br>
<Input type = submit name = \"submit\" value = \"Submit form\">
<Input type = reset name = \"reset\" value = \"Clear form\"
";
} else
{
$calc_tax = $amount + ($amount * ($rate / 100));
$amount = number_format($amount,2,'.','');
$calc_tax = number_format($calc_tax,2,'.','');
echo "
<body><h1> The calculated tax rate is as follows: </h1>
<table><tr><td> Enter Amount: </td>
<td>$ $amount </td></tr>
<tr><td> Entered Tax Rate: </td>
<td> $rate % </td></tr>
<tr><td> Calculated Tax Amount: </td>
<td>$ $calc_tax </td></tr>
</table>
<br>
<form action = \"taxcalc.php\" method =\"post\">
<input type = \"hidden\" name = \"SecondTime\" Value = \"\">
<Input type = submit name = \"submit\" value = \"Return to Calculator\">
";
}
?>
</body>
</html>
I'm just starting PHP, and have an old textbook with a simple tax calculator problem...
I have typed the code in as instructed, but cannot get the desired result...
I believe the book's example does not include varible declarations...
I have no idea what the SecondTime variable is for...
PLEASE HELP!!!
Here is my code...
-----------------------------------------------------------------------------------------------------------------------
<html>
<head>
<title> Sales Tax Calculator </title>
</head>
<?
if ($SecondTime == "")
{
echo "
<body><h1> Please enter amount and tax rate </h1>
<br>
<br>
<form action = \"taxcalc.php\" method = \"post\">
<input type = \"hidden\" name = \"SecondTime\" Value = 1>
Amount
<input type = text name\"amount\" size = 15><br><br>
Tax Rate:
<Input type = text name = \"rate\" size = 15><br><br>
<Input type = submit name = \"submit\" value = \"Submit form\">
<Input type = reset name = \"reset\" value = \"Clear form\"
";
} else
{
$calc_tax = $amount + ($amount * ($rate / 100));
$amount = number_format($amount,2,'.','');
$calc_tax = number_format($calc_tax,2,'.','');
echo "
<body><h1> The calculated tax rate is as follows: </h1>
<table><tr><td> Enter Amount: </td>
<td>$ $amount </td></tr>
<tr><td> Entered Tax Rate: </td>
<td> $rate % </td></tr>
<tr><td> Calculated Tax Amount: </td>
<td>$ $calc_tax </td></tr>
</table>
<br>
<form action = \"taxcalc.php\" method =\"post\">
<input type = \"hidden\" name = \"SecondTime\" Value = \"\">
<Input type = submit name = \"submit\" value = \"Return to Calculator\">
";
}
?>
</body>
</html>