Spam question incorrect";
$value=1;
}
//Now check if name is not filled in, if it's not we'll set the value to 1
if(empty($mail_name)){
$error_name="
Please fill in your name";
$value=1;
}
//Now check if subject is not filled in, if it's not we'll set the value to 1
if(empty($mail_subject)){
$error_subject="
Please add a subject to your email";
$value=1;
}
//Now check if message is not filled in, if it's not we'll set the value to 1
if(empty($mail_message)){
$error_message="
Please provide a message to be sent.";
$value=1;
}
//Now the fun part, we're going to check and see if the email is a normal looking email, if it's not we'll set the value to 1
if(!eregi('^[0-9a-z_\-]+@[0-9a-z_\-]+\.[a-z\.]+$',$mail_email)){
$error_email="
Please check that you have entered a correct email";
$value=1;
}
//Now we'll make sure they're not trying to add extra junk
if ( ereg( "[\r\n]", $mail_name ) || ereg( "[\r\n]", $mail_email ) || ereg( "[\r\n]", $mail_subject )) {
$value=1;
}
//So now if value still is 0 we'll send the email, if it's not, we'll show the email form again with the errors listed
//make sure you use put your email where it says YOUR-EMAIL@WHER-EVER-HERE
if($value == 0){
$to="your-email@yourdomain.com";
$headers = "From: \"".$mail_name."\" <".$mail_email.">\n";
$subject = $mail_subject;
$message = $mail_message;
$sent_it=@mail($to,$subject,$message,$headers);
}
}
//Now we'll check to see if the email was sent, if it was we'll say thanks or something, if not we'll show the form again
if($sent_it){
//So if it was sent, lets say Thanks for contacting me then put their name there, and say will get back to them
echo "Thanks for contacting me ".$mail_name.". I will get back to you soon!";
}else{
//if form hasn't been submitted or it had errors, we'll show the form again
?>