Make helloworld3
This commit is contained in:
parent
ca070249c9
commit
11d443985f
1 changed files with 37 additions and 0 deletions
37
helloworld3.php
Normal file
37
helloworld3.php
Normal 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>
|
Reference in a new issue