37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<title>Hello World 3</title>
|
||
|
</head>
|
||
|
<body>
|
||
|
<?php
|
||
|
$nb = 0;
|
||
|
$name = "";
|
||
|
if (isset($_GET["nb"]) AND isset($_GET["name"])) {
|
||
|
$nb = (int)$_GET["nb"];
|
||
|
$name = htmlspecialchars($_GET["name"]);
|
||
|
}
|
||
|
?>
|
||
|
<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>
|
||
|
|
||
|
<ul>
|
||
|
<?php
|
||
|
if ($nb AND $name) {
|
||
|
if ($nb >= 0 and $nb <= 100)
|
||
|
for ($i = 0; $i < $nb; $i++) { ?>
|
||
|
<li>Hello <?= $name ?> !</li>
|
||
|
<?php }
|
||
|
else { ?>
|
||
|
<strong>Invalid args !</strong>
|
||
|
<?php }
|
||
|
} ?>
|
||
|
</ul>
|
||
|
</body>
|
||
|
</html>
|