Files
2026-01-13 00:24:42 +01:00

49 lines
1.3 KiB
PHP

<?php
?>
<!doctype html>
<html lang="pl">
<head>
<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">
<meta charset="UTF-8">
<title>Z39 - Tak, Nie</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Zadanie Z39</h1>
<h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
<p>Napisz program, który Czyta wprowadzony znak z klawiatury i na „t” lub „T” wyświetla „TAK” na „n” lub „N” wyświetla „NIE” - na pozostałe znaki nie reaguję.</p>
</div>
<div class="box">
<form action="index.php" method="post">
<fieldset>
<label for="x">Podaj znak:</label>
<input type="text" required name="x" id="x">
</fieldset>
<button type="submit">Wyślij</button>
</form>
</div>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$x = htmlspecialchars($_POST['x']);
if (strlen($x) != 1) { return; }
if ($x == 't' || $x == 'T' || $x == 'n' || $x == 'N') {
echo '<div class="box">';
if ($x == 't' || $x == 'T') {
echo 'TAK';
} else if ($x == 'n' || $x == 'N') {
echo 'NIE';
}
echo '</div>';
}
}
?>
</body>
</html>