/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/php/php-507-161-003/main.php
23 строки
697 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
try { $stmt = $pdo->prepare( 'INSERT INTO subscribers (name, email, created_at) VALUES (:name, :email, :created_at)' ); $stmt->execute([ 'name' => $name, 'email' => $email, 'created_at' => (new DateTimeImmutable('now'))->format('Y-m-d H:i:s'), ]); } catch (PDOException $e) { // Дубликат email (код 23000 — integrity constraint) if ((int) ($e->errorInfo[1] ?? 0) === 1062) { header('Location: register.php?error=duplicate'); exit; } error_log($e->getMessage()); http_response_code(500); echo 'Ошибка сервера'; exit; } header('Location: thanks.php', true, 302); exit;