56 lines
1.5 KiB
PHP
56 lines
1.5 KiB
PHP
<?php
|
|
$children = 0;
|
|
$married = false;
|
|
$income = 0;
|
|
if (isset($_POST["children"]) AND isset($_POST["income"])) {
|
|
$children = (int)$_POST["children"];
|
|
if (isset($_POST["married"]))
|
|
$married = (bool)$_POST["married"];
|
|
else
|
|
$married = false;
|
|
$income = (float)$_POST["income"];
|
|
}
|
|
|
|
if ($married)
|
|
$n = 2+$children/2;
|
|
else
|
|
$n = 1+$children/2;
|
|
|
|
$q = $income/$n;
|
|
|
|
$t = 0;
|
|
if ($q >= 0 AND $q <= 9963)
|
|
$t = $income*0 - 0*$n;
|
|
elseif ($q <= 27518)
|
|
$t = $income*0.14 - 1394.96*$n;
|
|
elseif ($q <= 73778)
|
|
$t = $income*0.3 - 5798*$n;
|
|
elseif ($q <= 156243)
|
|
$t = $income*0.41 - 13913.69*$n;
|
|
elseif ($q >= 156244)
|
|
$t = $income*0.45 - 20163.45*$n;
|
|
|
|
$t = round($t);
|
|
echo $q;
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Hello World 4</title>
|
|
</head>
|
|
<body>
|
|
<form method="POST">
|
|
<label for="children">Number of children: </label>
|
|
<input id="children" type="number" name="children" min="0" value="<?= $children ?>" required> <br />
|
|
<label for="married">Married: </label>
|
|
<input id="married" type="checkbox" name="married" <?= $married ? "checked" : "" ?>> <br />
|
|
<label for="income">Income: </label>
|
|
<input id="income" type="number" name="income" min="0" step="any" value="<?= $income ?>" required> <br />
|
|
<input type="submit" value="Send">
|
|
</form>
|
|
|
|
<p>Your taxes is <?= $t ?></p>
|
|
</body>
|
|
</html>
|