From 1cb22384fd3495a9888de6b6520fdbdfc63e3859 Mon Sep 17 00:00:00 2001 From: spetznas Date: Sun, 17 May 2026 00:55:18 +0200 Subject: [PATCH] Commented out debug lines in rsvp-submit.php --- public/rsvp-submit.php | 86 ++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/public/rsvp-submit.php b/public/rsvp-submit.php index 972b139..fe4cf5a 100755 --- a/public/rsvp-submit.php +++ b/public/rsvp-submit.php @@ -1,38 +1,58 @@ safeLoad(); + +// Get form values +$first_name = $_POST['first_name'] ?? ''; +$last_name = $_POST['last_name'] ?? ''; +$name = trim("$first_name $last_name") ?: 'No Name'; + +// Drinks can be an array +$drinks = $_POST['drinks'] ?? 'None'; +if (is_array($drinks)) { + $drinks = implode(', ', $drinks); } -/* Honeypot spam protection */ -if (!empty($_POST['website'])) { - exit; // silently drop bot submission +// Allergies +$allergies = $_POST['allergies'] ?? 'None'; + +// Convert to UTF-8 +$name = mb_convert_encoding($name, 'UTF-8', 'auto'); +$drinks = mb_convert_encoding($drinks, 'UTF-8', 'auto'); +$allergies = mb_convert_encoding($allergies, 'UTF-8', 'auto'); + +// PHPMailer setup +$mail = new PHPMailer(true); +try { + $mail->CharSet = 'UTF-8'; + $mail->isSMTP(); + $mail->Host = $_ENV['SMTP_HOST']; + $mail->SMTPAuth = true; + $mail->Username = $_ENV['SMTP_USER']; + $mail->Password = $_ENV['SMTP_PASS']; + $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; + $mail->Port = (int)$_ENV['SMTP_PORT']; + + $mail->setFrom($_ENV['FROM_EMAIL'], $_ENV['FROM_NAME']); + $mail->addAddress($_ENV['TO_EMAIL']); + + $mail->Subject = mb_encode_mimeheader("New Wedding Guest: $name", 'UTF-8'); + + $body = <<Body = $body; + $mail->send(); + + echo 'RSVP submitted successfully.'; +} catch (Exception $e) { + echo "RSVP could not be sent. Mailer Error: {$mail->ErrorInfo}"; } - -/* Safely read form fields */ -$first_name = htmlspecialchars($_POST['first_name'] ?? ''); -$last_name = htmlspecialchars($_POST['last_name'] ?? ''); - -$drinks = isset($_POST['drinks']) ? implode(", ", $_POST['drinks']) : "None"; -$allergies = htmlspecialchars($_POST['allergies'] ?? ''); - -if (!$first_name || !$last_name) { - exit("Missing required fields"); -} - -/* Email setup */ -$to = "hochzeit@markinstefan.xyz"; -$subject = "New Wedding RSVP from $first_name $last_name"; - -$message = "Name: $first_name $last_name\n"; -$message .= "Drinks: $drinks\n"; -$message .= "Allergies: $allergies\n"; - -$headers = "From: no-reply@yourdomain.com\r\n"; -$headers .= "Reply-To: no-reply@yourdomain.com\r\n"; - -/* Send mail */ -mail($to, $subject, $message, $headers); - -echo "Thank you! Your RSVP has been sent."; -?>