
<?php
$name = trim((string)($_POST['name'] ?? '')); $email = trim((string)($_POST['email'] ?? '')); $message = trim((string)($_POST['message'] ?? ''));
if ($name !== '' && $email !== '' && $message !== '') {
  $file = __DIR__ . '/data/contact_messages.txt';
  $line = uniqid() . '|' . str_replace(["
","
","|"],' ', $name) . '|' . str_replace(["
","
","|"],' ', $email) . '|' . str_replace('|','/', $message) . '|' . date('Y-m-d H:i:s') . PHP_EOL;
  file_put_contents($file, $line, FILE_APPEND);
}
header('Location: /contact.php?sent=1'); exit;
