49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
?>
|
|
<!doctype html>
|
|
<html lang="pl">
|
|
<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>Z36 - Podzielność liczb</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1>Zadanie Z36</h1>
|
|
<h2>Autor: Jakub Grzegorczyk</h2>
|
|
</header>
|
|
<div class="box">
|
|
<p>Napisz program, który: dla liczb całkowitych (program powinien sprawdzić, czy liczby są całkowite) A i B sprawdza czy A jest podzielne przez B (wykorzystaj funkcję zwracającą resztę z dzielenia).</p>
|
|
</div>
|
|
<div class="box">
|
|
<form action="index.php" method="post">
|
|
<fieldset>
|
|
<label for="a">Podaj A:</label>
|
|
<input type="number" name="a" id="a" required>
|
|
<label for="b">Podaj B:</label>
|
|
<input type="number" name="b" id="b" required>
|
|
</fieldset>
|
|
<button type="submit">Wyślij</button>
|
|
</form>
|
|
</div>
|
|
<?php
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
$a = htmlspecialchars($_POST['a']);
|
|
$b = htmlspecialchars($_POST['b']);
|
|
echo '<div class="box">';
|
|
echo "a = $a<br>";
|
|
echo "b = $b<br>";
|
|
if ($a % $b == 0) {
|
|
echo "Liczba $a jest podzielna przez $b";
|
|
} else {
|
|
echo "Liczba $a nie jest podzielna przez $b";
|
|
}
|
|
echo '</div>';
|
|
}
|
|
?>
|
|
</body>
|
|
</html>
|