Jump to content

Image Verification Mail Script - Added Field


Helniev

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 = '[email protected]';

  $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 = '[email protected]';
   $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 = '[email protected]' . ', ';
   $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>';
};
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.