Helniev Posted March 8, 2007 Share Posted March 8, 2007 Hi guys, first time poster here! I recently got a PHP mail form with image verification for our website, it works good but I wuld like to add a component, and do not know PHP very well... so here is the script <? session_start(); if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') { echo '<strong>Incorrect verification code.</strong><br>'; } else { $recipient = 'thatguy@thatwebsite.com'; $subject = $_POST['Subject']; $from = stripslashes($_POST['Name']); $msg = "Message from: $from\n\n".stripslashes($_POST['MsgBody']); mail($recipient, $subject, $msg); echo '<strong>Verification successful.</strong><br>'; }; ?> What I would like to do is add a "reply-to" line, I am using the "subject" field on the form, for the visitor to enter their e-mail instead of the subject. is there a way i can use that item to use as a "reply-to" when i want to email that person back? Thanks a bunch in advance! Quote Link to comment https://forums.phpfreaks.com/topic/41849-image-verification-mail-script-added-field/ Share on other sites More sharing options...
quasiman Posted March 9, 2007 Share Posted March 9, 2007 This should work <?php session_start(); if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') { echo '<strong>Incorrect verification code.</strong>'; } else { $recipient = 'thatguy@thatwebsite.com'; $recipient .= ', 'stripslashes($_POST['ReplyTo']); // <-- Add a field in your form named "ReplyTo" $subject = $_POST['Subject']; $from = stripslashes($_POST['Name']); $msg = "Message from: $from\n\n".stripslashes($_POST['MsgBody']); mail($recipient, $subject, $msg); echo '<strong>Verification successful.</strong>'; }; ?> Quote Link to comment https://forums.phpfreaks.com/topic/41849-image-verification-mail-script-added-field/#findComment-203057 Share on other sites More sharing options...
Helniev Posted March 9, 2007 Author Share Posted March 9, 2007 Thanks for your answer! unfortunately, it didn't work, got this message when testing "Parse error: parse error, unexpected T_STRING in /home/www/mysite.com/submit.php on line 7" I hate that because all the PHP mail sent from the website comes with the same "from" email address, which is an email from the website itself, they dont realise it and just hit "reply" and the mail bounces back to them... DOH Quote Link to comment https://forums.phpfreaks.com/topic/41849-image-verification-mail-script-added-field/#findComment-203585 Share on other sites More sharing options...
quasiman Posted March 9, 2007 Share Posted March 9, 2007 oh, oops...sorry, my bad - this works: <?php session_start(); if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') { echo '<strong>Incorrect verification code.</strong>'; } else { $recipient = 'thatguy@thatwebsite.com' . ', '; $recipient .= stripslashes($_POST['ReplyTo']); // <-- Add a field in your form named "ReplyTo" $subject = $_POST['Subject']; $from = stripslashes($_POST['Name']); $msg = "Message from: $from\n\n".stripslashes($_POST['MsgBody']); mail($recipient, $subject, $msg); echo '<strong>Verification successful.</strong>'; }; ?> Quote Link to comment https://forums.phpfreaks.com/topic/41849-image-verification-mail-script-added-field/#findComment-203615 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.