Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Need advise on getting the reply function working

$
0
0

Hi,

 

I need some advise on getting this contact form working correctly,

It emails the message as it should but I need to have a reply header in there somewhere so the user can click reply in their email program to send an email back..

 

At the moment, it just replies to the website it came from.

 

Hope this makes sense.

 


 

<?php
 
 
// get posted data into local variables
 
$EmailTo = "me@mysite.co.uk";
$Subject = "Contact Form:";
$Name = Trim(stripslashes($_POST['Name'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Phone = Trim(stripslashes($_POST['Phone'])); 
$Comments = Trim(stripslashes($_POST['Comments'])); 
 
 
//Assigning the REPLY FUNCTION
$headers  = "From: me@mysite.co.uk.co.uk\r\n";
$headers .= "Reply-To: " . $email . "\n" ;
 
 
 
 
// validation
$validationOK=true;
if (Trim($Name)=="") $validationOK=false;
if (Trim($Email)=="") $validationOK=false;
if (Trim($Comments)=="") $validationOK=false;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contact-fields.php\">";
  exit;
}
 
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $Comments;
$Body .= "\n";
 
// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
 
// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contact-ok.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contact-error.php\">";
}
?>

 


Viewing all articles
Browse latest Browse all 13200

Trending Articles