Log in

View Full Version : php auto response help!



nathanw
08-16-2010, 04:50 PM
can someone help me come up with a code that would generate auto response when the person submits the form and gets a thank you message.

Here are my php code

<?php
// Change the 2 variables below
$yourEmail = 'kalok626@hotmail.com'; //Your email address. mails will go here
$yourSubject = 'testing'; //mail subject
$from = $_GET['email'];

if(!empty($_COOKIE['feedback'])) die('<p style="color:red;">You can\'t send another feedback within 30 seconds</p>');

if(!empty($_GET['feedback'])){
if(empty($_GET['name']) || empty($_GET['email']) || empty($_GET['subject']) || empty($_GET['comment'])) die("Please fill fields");

$msg ="Name: ".$_GET['name']."<br/><br/>";
$msg.="Subject: ".$_GET['subject']."<br/><br/>";
$msg.="Message: ".$_GET['comment'];


//set mail headers
$headers="Mime-Version:1.0\r\n";
$headers.="Content-type:text/html; charset=utf-8\r\n";

/* additional headers */
$headers .= "From: ".$_GET['email']."\r\n";
$headers .="Subject: $yourSubject \r\n";

if (mail($yourEmail,$yourSubject,$msg,$headers)) {
setcookie("feedback","sent",time()+30);
echo '<span style="color:green;font-weight:bold;">Thank You, we will get back to you within 24 hours!</span>';
} else {
echo '<p style="color:red;">Failure! There are some while sending email. Please send mail to '.$yourEmail.'</p>';
}
}

?>

nathanw
08-17-2010, 02:59 PM
If someone can give me an answer to this I would really appreciate.