Correction
This commit is contained in:
parent
7eb62d14ef
commit
62edb91f95
4 changed files with 75 additions and 60 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
<?php
|
||||||
|
if (isset($_GET["nb"])) {
|
||||||
|
$nb = (int)$_GET["nb"];
|
||||||
|
if ($nb < 0 and $nb > 100)
|
||||||
|
$nb = null;
|
||||||
|
} else
|
||||||
|
$nb = null;
|
||||||
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
@ -7,9 +16,7 @@
|
||||||
<body>
|
<body>
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
if (isset($_GET["nb"])) {
|
if ($nb !== null) {
|
||||||
$nb = (int) $_GET["nb"];
|
|
||||||
if ($nb >= 0 and $nb <= 100)
|
|
||||||
for ($i = 0; $i < $nb; $i++) { ?>
|
for ($i = 0; $i < $nb; $i++) { ?>
|
||||||
<li>Hello World !</li>
|
<li>Hello World !</li>
|
||||||
<?php }
|
<?php }
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
<?php
|
||||||
|
$nb = null;
|
||||||
|
$name = null;
|
||||||
|
$error = false;
|
||||||
|
if (isset($_GET["nb"]) AND isset($_GET["name"])) {
|
||||||
|
$nb = (int)$_GET["nb"];
|
||||||
|
$name = htmlspecialchars($_GET["name"]);
|
||||||
|
if ($nb < 0 or $nb > 100) {
|
||||||
|
$error = true;
|
||||||
|
$nb = null;
|
||||||
|
$name = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
@ -5,14 +20,6 @@
|
||||||
<title>Hello World 3</title>
|
<title>Hello World 3</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php
|
|
||||||
$nb = 0;
|
|
||||||
$name = "";
|
|
||||||
if (isset($_GET["nb"]) AND isset($_GET["name"])) {
|
|
||||||
$nb = (int)$_GET["nb"];
|
|
||||||
$name = htmlspecialchars($_GET["name"]);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<form>
|
<form>
|
||||||
<label for="nb">Number: </label>
|
<label for="nb">Number: </label>
|
||||||
<input id="nb" type="number" name="nb" min="0" max="100" value="<?= $nb ?>" required>
|
<input id="nb" type="number" name="nb" min="0" max="100" value="<?= $nb ?>" required>
|
||||||
|
@ -21,16 +28,16 @@
|
||||||
<input type="submit" value="Send">
|
<input type="submit" value="Send">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<ul>
|
|
||||||
<?php
|
<?php
|
||||||
if ($nb AND $name) {
|
if ($error) { ?>
|
||||||
if ($nb >= 0 and $nb <= 100)
|
<strong>Invalid args !</strong>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<?php if ($nb !== null AND $name !== null) {
|
||||||
for ($i = 0; $i < $nb; $i++) { ?>
|
for ($i = 0; $i < $nb; $i++) { ?>
|
||||||
<li>Hello <?= $name ?> !</li>
|
<li>Hello <?= $name ?> !</li>
|
||||||
<?php }
|
<?php }
|
||||||
else { ?>
|
|
||||||
<strong>Invalid args !</strong>
|
|
||||||
<?php }
|
|
||||||
}?>
|
}?>
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -1,33 +1,16 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Hello World 4</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<?php
|
<?php
|
||||||
$children = 0;
|
$children = 0;
|
||||||
$married = false;
|
$married = false;
|
||||||
$income = 0;
|
$income = 0;
|
||||||
if (isset($_GET["children"]) AND isset($_GET["income"])) {
|
if (isset($_POST["children"]) AND isset($_POST["income"])) {
|
||||||
$children = (int)$_GET["children"];
|
$children = (int)$_POST["children"];
|
||||||
if (isset($_GET["married"]))
|
if (isset($_POST["married"]))
|
||||||
$married = (bool)$_GET["married"];
|
$married = (bool)$_POST["married"];
|
||||||
else
|
else
|
||||||
$married = false;
|
$married = false;
|
||||||
$income = (float)$_GET["income"];
|
$income = (float)$_POST["income"];
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
<form>
|
|
||||||
<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>
|
|
||||||
<?php
|
|
||||||
if ($married)
|
if ($married)
|
||||||
$n = 2+$children/2;
|
$n = 2+$children/2;
|
||||||
else
|
else
|
||||||
|
@ -38,18 +21,36 @@
|
||||||
$t = 0;
|
$t = 0;
|
||||||
if ($q >= 0 AND $q <= 9963)
|
if ($q >= 0 AND $q <= 9963)
|
||||||
$t = $income*0 - 0*$n;
|
$t = $income*0 - 0*$n;
|
||||||
elseif ($q >= 9964 AND $q <= 27518)
|
elseif ($q <= 27518)
|
||||||
$t = $income*0.14 - 1394.96*$n;
|
$t = $income*0.14 - 1394.96*$n;
|
||||||
elseif ($q >= 27519 AND $q <= 73778)
|
elseif ($q <= 73778)
|
||||||
$t = $income*0.3 - 5798*$n;
|
$t = $income*0.3 - 5798*$n;
|
||||||
elseif ($q >= 73779 AND $q <= 156243)
|
elseif ($q <= 156243)
|
||||||
$t = $income*0.41 - 13913.69*$n;
|
$t = $income*0.41 - 13913.69*$n;
|
||||||
elseif ($q >= 156244)
|
elseif ($q >= 156244)
|
||||||
$t = $income*0.45 - 20163.45*$n;
|
$t = $income*0.45 - 20163.45*$n;
|
||||||
|
|
||||||
$t = round($t);
|
$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>
|
<p>Your taxes is <?= $t ?></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Reference in a new issue