<?php
require_once __DIR__ . '/../config/helpers.php';

$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$phone = trim($_POST['phone'] ?? '');
$message = trim($_POST['message'] ?? '');

if ($name === '' || $email === '' || $message === '') {
    header('Location: index.php#contact');
    exit;
}

$pdo = db();
$stmt = $pdo->prepare("INSERT INTO contact_messages (name, email, phone, message) VALUES (?,?,?,?)");
$stmt->execute([$name, $email, $phone, $message]);

header('Location: index.php#contact');
exit;
