Log in

View Full Version : Help with my autoresponder



MKjunior
10-27-2008, 03:09 PM
Hi i am in need of some help:

I have created a php contact form but am now in need of making my contact form send an automatic response back:

Can anyone help me with this at all, Im rather new to PHP and have driven myself mad trying to figure this out:



<?php

$myemail = "martin.s.kilner@googlemail.com";


$yourname = check_input($_POST['yourname'], "Enter your name");
$email = check_input($_POST['email'], " Enter your email");
$number = check_input($_POST['number']);
$comments = check_input($_POST['comments']);

$from_name = "Martin Kilner";

$headers = "From: {$from_name} <{$myemail}>";


if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}


$messageone = "Hello!

Your contact form has been submitted by:

Name: $yourname
E-mail: $email
number: $number



Comments:
$comments

End of message
";

$messagetwo = "contact info";

mail($myemail, $messagetwo, $messageone);

header('Location: index.html');
exit();



function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}

function show_error($myError)
{





$messagethree = "Thank You for your submission";

$subject = "Received";

$headers = "From: {$from_name} <{$myemail}>";

// send email
$success = mail($myemail, $Subject, $messagethree, "From: <$from_name>");


//mail($_REQUEST['email'],$subject,$messagethree,$headers);

?>
<html>
<body>

<b>Please correct the following error:</b><br />
<?php echo $myError; ?>

</body>
</html>


<?php
exit();
}
?>




Thank you :(