37494-vm/add_contact.php
Flatlogic Bot de0994c87d Optera1
2026-01-16 01:34:36 +00:00

23 lines
619 B
PHP

<?php
require_once 'db/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST['name'] ?? '';
$email = $_POST['email'] ?? '';
$phone = $_POST['phone'] ?? '';
if (!empty($name)) {
try {
$pdo = db();
$stmt = $pdo->prepare("INSERT INTO contacts (name, email, phone) VALUES (?, ?, ?)");
$stmt->execute([$name, $email, $phone]);
} catch (PDOException $e) {
// In a real app, you'd log this error.
// For now, we'll just ignore it for this simple example.
}
}
}
header('Location: index.php');
exit;
?>