This commit is contained in:
FlyInTheBox 2023-03-01 13:37:43 +01:00
parent d255e3163d
commit 288c09d171

View file

@ -0,0 +1,37 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="index.php" method="post">
<fieldset>
<legend>Liczby</legend>
<?PHP
$arr = range(0, 100, 10);
foreach ($arr as $value) {
echo '<label for="check"><input type="checkbox" name="check[]" value="' . $value . '" id="box' . $value . '">' . $value . '</label>';
}
echo '<br><button type="submit">Wyślij</button>';
?>
<br><br>
<?PHP
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (empty($_POST['check'])) {
echo 'Nie wybrano żadnych liczb.';
} else {
echo 'Wybrano liczby: ';
foreach ($_POST['check'] as $value) {
echo $value . ', ';
}
}
}
?>
</fieldset>
</form>
</body>
</html>