23 lines
619 B
PHP
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;
|
|
?>
|