Jump to content

Recommended Posts

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!

 

 

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>';
};
?>

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

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>';
};
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.