1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
PHP_TP1/helloworld4.php

57 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2020-10-01 08:41:35 +02:00
<?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;
?>
2020-09-10 16:01:09 +02:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello World 4</title>
</head>
<body>
2020-10-01 08:41:35 +02:00
<form method="POST">
2020-09-10 16:01:09 +02:00
<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>
2020-10-01 08:41:35 +02:00
</html>