/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/php/php-507-151-013/main.php
30 строк
676 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
<?php declare(strict_types=1); if ($_SERVER["REQUEST_METHOD"] !== "POST") { http_response_code(405); exit; } $input = [ "email" => trim((string)($_POST["email"] ?? "")), "message" => trim((string)($_POST["message"] ?? "")), ]; $errors = []; if (!filter_var($input["email"], FILTER_VALIDATE_EMAIL)) { $errors["email"] = "Некорректный email"; } if ($input["message"] === "") { $errors["message"] = "Сообщение обязательно"; } if ($errors !== []) { http_response_code(422); // Вернуть ошибки в шаблон или JSON exit; } // saveMessage($input); header("Location: /thank-you.php"); exit;