Rewrote rsvp-submit.php again #2

This commit is contained in:
spetznas
2026-05-16 23:08:43 +02:00
parent b111696c26
commit 7ce7b4f179
+13 -4
View File
@@ -1,13 +1,21 @@
<?php <?php
require __DIR__ . '/vendor/autoload.php'; // PHPMailer require __DIR__ . '/../vendor/autoload.php'; // adjust path if needed
use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\Exception;
// Load .env // Load .env from /var/www/markinstefan.xyz/.env
if (!file_exists(__DIR__ . '/.env')) { $envPath = '/var/www/markinstefan.xyz/.env';
if (!file_exists($envPath)) {
exit('Missing .env file!'); exit('Missing .env file!');
} }
$dotenv = parse_ini_file(__DIR__ . '/.env', false, INI_SCANNER_RAW);
// Simple parser for key=value lines
$dotenv = [];
foreach (file($envPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {
if (preg_match('/^\s*([A-Z_]+)\s*=\s*(.*)\s*$/', $line, $matches)) {
$dotenv[$matches[1]] = trim($matches[2], "\"'");
}
}
// Form validation // Form validation
if ($_SERVER['REQUEST_METHOD'] !== 'POST') exit('Invalid request'); if ($_SERVER['REQUEST_METHOD'] !== 'POST') exit('Invalid request');
@@ -48,3 +56,4 @@ try {
error_log("Mailer Error: {$mail->ErrorInfo}"); error_log("Mailer Error: {$mail->ErrorInfo}");
echo "Sorry, something went wrong. Please try again later."; echo "Sorry, something went wrong. Please try again later.";
} }
?>