<?php
require_once __DIR__ . '/../includes/redirect_helper.php';
// Collect form data
$name    = $_POST['name'] ?? '';
$email   = $_POST['email'] ?? '';
$subject = $_POST['subject'] ?? '';
$message = $_POST['message'] ?? '';

// Save contact message to file
$saveFile = __DIR__ . '/data/contact_messages.txt';
$entry = "Name: $name\nEmail: $email\nSubject: $subject\nMessage: $message\n---\n";
file_put_contents($saveFile, $entry, FILE_APPEND);

// Redirect back with success message
ah_redirect_back('/contact.php', ['sent' => 1]);
