1
0
Fork 0

Make helloworld3

This commit is contained in:
Ethanell 2020-09-10 15:56:55 +02:00
parent ca070249c9
commit 11d443985f

37
helloworld3.php Normal file
View file

@ -0,0 +1,37 @@
<!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>