i get the full code when i try to run the php in my html file.
[php]<?
if(isset($_POST[‘email’])){
// here is the email to information
$email_to = "your email goes here";
$email_subject = "This is form your website contact form";
$email_from = "TheTechTalkBlog"
//error code
public function died($error){
echo "We are sorry, there were error(s) found with the form you submitted.";
echo "These errors appear below.<br/><br/>";
echo $error."<br/><br/>";
echo "Please go back and fix these errors.<br/";
die();
}
//validation
if(!isset($_POST['name']) ||
if(!isset($_POST['email']) ||
if(!isset($_POST['comments'])){
died("We are sorry but there appears to be a problem with the form you submitted");
}
$name = $_POST['name'];
$name = $_POST['email'];
$name = $_POST['comments'];
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp, $email)){
$error_message .= 'The Email address you entered does not appear to be valid<br/>';
}
$string_exp = "/^[A-Za-z.'-]+$/";
if(!preg_match($string_exp, $name)){
$error_message .= 'The name you entered does not appear to be valid<br/>';
}
if(strlen($comments) < 2){
$error_message .= 'The comments you entered do no appear to to be valid<br/>';
}
if(strlen($error_message) > 0 ) {
died($error_message);
}
$email_message = "Form details below. \n\n";
fuction clean_string($string){
$bad = array("content-type", "bcc:", "to:", "cc:",
"href";);
}
email_message .= "Name:" . clean_string($name) . "\n";
email_message .= "Email:" . clean_string($name) . "\n";
email_message .= "Comments:" . clean_string($name) . "\n";
//create email headers
$headers = 'From:' .$email_from . "\r\n". 'Reply-To:' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
Thank you for contacting us. We will be in touch with you shortly.
Please click<a href = "home.html"here to go home to the home page.