Hello:
These 2 functions are not working in the code below, please suggest any rectifications. The functions are IS_NUMERIC to check the values entered are numeric and ISSET to make sure that they submit values at all.
These 2 functions are not working in the code below, please suggest any rectifications. The functions are IS_NUMERIC to check the values entered are numeric and ISSET to make sure that they submit values at all.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title> Tax Calc Form </title>
<style type="text/css" media="screen">.number {font-weight: bold;} </style>
</head>
<body>
<form action="taxcalc.php" method="post">
<p> Enter Amount of Income <input type="text"
name="amount" size="20" /></p>
<input type="submit" name="submit"
value="Submit" />
<h1> Tax Calculator </h1>
</form>
<?php
/* This script takes values from above and use them in the function below. */
//
if(isset($_POST['submitted'])){
}
//Variable starts Here
$amount=$_POST['amount'];
//Check amount range function
function income_is_valid($amount){
if (is_numeric($_POST['amount']>0) AND is_numeric($_POST['amount'] < 1000000000)) {
$amt=$amount;
return $amt;
}
else {
die('<p style="color:red;">This is not a VALID Amount. Please enter a value between 0 and 1 million!</p>');
}
}//end of range function
//tax rate function
function tax_rate($amount){
if ($amount<50000){
$tax_deduct=0;
}
elseif(($amount>=50000) AND ($amount <= 500000)){
$tax_deduct=$amount*0.10;
}
elseif($amount >500000){
$tax_deduct=$amount*0.15;
}
else{
;
}
return $tax_deduct;
}
//Call functions
$amt=income_is_valid($amount);
$tax_deduct=tax_rate($amount);
$net_pay=($amt - $tax_deduct);
else {
die('<p style="color:red;">Please enter a valid firstname, lastname, department and Jobtitle!</p>');
}
//print result
print "<p><div>
Pay Amount is :<span class=\"text\">$amt</span><br />
Your Tax Deduction is :<span class=\"text\">$tax_deduct</span><br />
Your Net Pay : <span class=\"text\">$net_pay</span></p></div>"
?>
</body>
</html>