44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?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>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Hello World 3</title>
|
|
</head>
|
|
<body>
|
|
<form>
|
|
<label for="nb">Number: </label>
|
|
<input id="nb" type="number" name="nb" min="0" max="100" value="<?= $nb ?>" required>
|
|
<label for="name">Name: </label>
|
|
<input id="name" name="name" value="<?= $name ?>" required>
|
|
<input type="submit" value="Send">
|
|
</form>
|
|
|
|
<?php
|
|
if ($error) { ?>
|
|
<strong>Invalid args !</strong>
|
|
<?php } ?>
|
|
|
|
<ul>
|
|
<?php if ($nb !== null AND $name !== null) {
|
|
for ($i = 0; $i < $nb; $i++) { ?>
|
|
<li>Hello <?= $name ?> !</li>
|
|
<?php }
|
|
}?>
|
|
</ul>
|
|
</body>
|
|
</html>
|