Hi,
I am trying to validate email then send the email if correct email. Below code is not working for me.
any help?
Thanks.
<?php
$errors = '';
$myemail = 'example@example.com';
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
Else
mail("example@example.com", "$subject", $message, "From:" . $email);
echo "Thank you for using our mail form";
?>
--i entered invalid email address but it cant verify that it is invalid. i was expecting error message. if valid email, then just send the email.
Thanks.