<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Форма</title>
<style>
body {
font-family: sans-serif;
padding: 20px;
}
form {
max-width: 300px;
display: flex;
flex-direction: column;
gap: 10px;
}
input,
textarea,
button {
padding: 8px;
}
.result {
margin-top: 20px;
padding: 10px;
border: 1px solid #ccc;
background: #f9f9f9;
}
</style>
</head>
<body>
<h2>Заполните данные</h2>
<form method="POST">
<input type="text" name="name" placeholder="Имя" required>
<input type="tel" name="phone" placeholder="Телефон" required>
<input type="email" name="email" placeholder="Почта" required>
<textarea name="comment" placeholder="Комментарий" required></textarea>
<button type="submit">Отправить</button>
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = htmlspecialchars($_POST["name"]);
$phone = htmlspecialchars($_POST["phone"]);
$email = htmlspecialchars($_POST["email"]);
$comment = htmlspecialchars($_POST["comment"]);
echo "
<div class='result'>
<h3>Полученные данные:</h3>
<p><strong>Имя:</strong> $name</p>
<p><strong>Телефон:</strong> $phone</p>
<p><strong>Почта:</strong> $email</p>
<p><strong>Комментарий:</strong> $comment</p>
</div>
";
}
?>
</body>
</html>