Here's the error I got :
Warning: preg_match() [function.preg-match]: Compilation failed: range out of order in character class at offset 12 in /home/tc81/public_html/mktgsi/contact/index.php on line 60
false
And here my current code :
Code: Select all
<?php
function is_valid_email($mail)
{
if(preg_match("/[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $mail) > 0)
{
return true;
}
else
{
return false;
}
}
$to = "---@---.---";
$subject = $_REQUEST['title'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $email";
$send = is_valid_email($email);
If ($send)
{echo "true";}
else
{echo "false";}
if (!$email=="")
{
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{echo "<script>alert('your mail was sent successfully')</script>";}
else
{print "We encountered an error sending your mail";}
}
?>