From 37b6f6fd813a7ef03e1f409524ba7975ac0d6ba4 Mon Sep 17 00:00:00 2001
From: Daniel Winzen <daniel@danwin1210.de>
Date: Sat, 7 Oct 2023 17:30:29 +0200
Subject: [PATCH] Add email field to contact form

---
 contact.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/contact.php b/contact.php
index c7e7e66..3d3ddaf 100644
--- a/contact.php
+++ b/contact.php
@@ -31,6 +31,9 @@ global $language, $dir, $locale;
 echo htmlspecialchars($_POST['name'] ?? '');
 ?>" autofocus></label><br>
 <div <?php echo empty($_POST['subject']) ? 'hidden' : ''; ?>><label><?php echo htmlspecialchars(_('Honeypot (do not fill anything):')); ?> <input type="text" name="subject" value="<?php echo htmlspecialchars($_POST['subject'] ?? ''); ?>"></label><br></div>
+<label><?php echo htmlspecialchars(_('Your email:')); ?> <br><input name="your_email" type="email" size="30" value="<?php
+echo htmlspecialchars($_POST['your_email'] ?? '');
+?>"></label><br>
 <label><?php echo htmlspecialchars(_('Subject:')); ?> <br><input name="real_subj" size="30" value="<?php
 echo htmlspecialchars($_POST['real_subj'] ?? '');
 ?>"></label><br>
@@ -61,6 +64,9 @@ if($_SERVER['REQUEST_METHOD']==='POST'){
 		$message.= _('You haven\'t entered a message yet.').'<br>';
 		$ok=false;
 	}
+	if(!empty($_POST['your_email'])){
+		$headers .= "Reply-To: $name <".filter_var($_POST['your_email'], FILTER_SANITIZE_EMAIL).">\r\n";
+	}
 	if(!empty($_POST['real_subj'])){
 		$subject="$_POST[real_subj]";
 	}