Files
2p_pracownia_programowania_php/Zadania/Z35 - proste prostopadłe/index.php
2026-01-13 00:24:42 +01:00

60 lines
2.0 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>Z35 - Proste prostopadłe</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Zadanie Z35</h1>
<h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
<p>Napisz program, który dla podanych dwóch równań prostych odpowie czy proste te są prostopadłe.</p>
</div>
<div class="box">
<form action="index.php" method="post">
<fieldset>
<legend>Współczynniki: </legend>
<label for="a1">Współczynnik a<sub>1</sub>:</label>
<input type="number" name="a1" id="a1">
<label for="b1">Współczynnik b<sub>1</sub>:</label>
<input type="number" name="b1" id="b1">
<label for="a2">Współczynnik a<sub>2</sub>:</label>
<input type="number" name="a2" id="a2">
<label for="b2">Współczynnik b<sub>2</sub>:</label>
<input type="number" name="b2" id="b2">
</fieldset>
<button type="submit">Sprawdź równoległość</button>
</form>
</div>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$a1 = $_POST['a1'];
$b1 = $_POST['b1'];
$a2 = $_POST['a2'];
$b2 = $_POST['b2'];
echo "<div class='box'>";
echo "<p>a<sub>1</sub> = {$a1}<br>b<sub>1</sub> = {$b1}<br>a<sub>2</sub> = {$a2}<br>b<sub>2</sub> = {$b2}</p>";
echo "<p>f(x) = a<sub>1</sub>x + b<sub>1</sub> = {$a1}x + {$b1}</p>";
echo "<p>f(x) = a<sub>2</sub>x + b<sub>2</sub> = {$a2}x + {$b2}</p>";
if ($a1 * $a2 == -1) {
echo "<p style='color: green; font-weight: bold;'>Proste są prostopadłe.</p>";
} else {
echo "<p style='color: red; font-weight: bold;'>Proste NIE są prostopadłe.</p>";
}
echo "</div>";
}
?>
</body>
</html>