"; if ($_GET['error'] == 'captcha') echo "❌ Bitte bestätigen Sie das reCAPTCHA!"; if ($_GET['error'] == 'fields') echo "❌ Bitte alle Pflichtfelder ausfüllen!"; if ($_GET['error'] == 'mail') echo "❌ Fehler beim Senden der E-Mail!"; if ($_GET['error'] == 'curl') echo "❌ Serverfehler!"; if ($_GET['error'] == 'bot') echo "❌ Anfrage zu schnell gesendet!"; echo "

Sie werden weitergeleitet..."; echo ""; } if (isset($_GET['success'])) { echo "
✅ Ihre Nachricht wurde erfolgreich gesendet!

Sie werden weitergeleitet...
"; echo ""; } // ===== FORMULAR VERARBEITEN ===== if ($_SERVER["REQUEST_METHOD"] == "POST") { // ⏱️ BOT SCHUTZ (Zeitprüfung) $form_time = $_POST['form_time'] ?? 0; $current_time = time(); // Zeitdifferenz berechnen $diff = $current_time - (int)$form_time; // Wenn Formular zu schnell abgeschickt wurde → blockieren if ($diff < 3) { header("Location: kontakt.php?error=bot"); exit(); } $secret = "6LfATb4sAAAAANpSFmh_5j0WHVWyAAOxfGrUthMl"; // <-- HIER DEIN KEY $response = $_POST['g-recaptcha-response'] ?? ''; // ❌ kein Captcha if (empty($response)) { header("Location: kontakt.php?error=captcha"); exit(); } // ===== GOOGLE CHECK ===== $ch = curl_init("https://www.google.com/recaptcha/api/siteverify"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, [ 'secret' => $secret, 'response' => $response ]); $verify = curl_exec($ch); if ($verify === false) { header("Location: kontakt.php?error=curl"); exit(); } curl_close($ch); $captcha = json_decode($verify); if (!$captcha || !$captcha->success) { header("Location: kontakt.php?error=captcha"); exit(); } // ===== DATEN ===== $anrede = $_POST['anrede'] ?? ''; $name = $_POST['name'] ?? ''; $firma = $_POST['firma'] ?? ''; $email = $_POST['email'] ?? ''; $telefon = $_POST['telefon'] ?? ''; $nachricht = $_POST['nachricht'] ?? ''; // ❌ Pflichtfelder if (empty($name) || empty($email) || empty($nachricht)) { header("Location: kontakt.php?error=fields"); exit(); } // ===== MAIL ===== $to = "elektro@hotwagner.eu"; $subject = "Neue Anfrage von der Website"; $message = "Anrede: $anrede\n"; $message .= "Name: $name\n"; $message .= "Firma: $firma\n"; $message .= "E-Mail: $email\n"; $message .= "Telefon: $telefon\n\n"; $message .= "Nachricht:\n$nachricht"; // ⚠️ wichtig für world4you $headers = "From: noreply@hotwagner.eu\r\n"; $headers .= "Reply-To: $email\r\n"; if (mail($to, $subject, $message, $headers)) { header("Location: kontakt.php?success=1"); exit(); } else { header("Location: kontakt.php?error=mail"); exit(); } } ?>