<?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
header("Location: contact.php?sent=1");
exit;
