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/helloworld3.php
2020-09-10 15:56:55 +02:00

37 lines
No EOL
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>