继续收到“无效的电子邮件”[关闭]

I keep getting invalid email. Please help! I am new to forms. I have a form in html action is send info to this php. ot sure what the problem is but does it matter if there is two email validation? I have this php page and a jQuery, both validating the email. not sure if that is the affecting this.

<?php 
$errors = '';
$myemail = 'something@something.com';
if(empty($_POST['contact_name'])  || 
   empty($_POST['contact_email']) || 
   empty($_POST['contactcomment']))
{
    $errors .= "
 Error: all fields are required";
}

$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 

if(filter_var($email_address,FILTER_VALIDATE_EMAIL) === false)
{
    echo 'Email is not valid';
}
else
{

} 

You're checking to see if $_POST['contact_email'] is empty but passing the value of $_POST['email'] to $email_address, I'm assuming that contact_email is the one you want since that is the one you're checking to see if its empty or not. So email will either be empty or something@something none of which is a valid email.

So simply change:

$email_address = $_POST['email']; 

to:

$email_address = $_POST['contact_email']; 

something@something is not a valid email. The function is working correctly, the email you've input is invalid.

Unless you're providing something different in $_POST['email_address'];

You are missing .com

$myemail = 'something@something.com';

and check your

echo $email_address = $_POST['email']; You are using this value in your function.

in if condition you are using $_POST['contact_email'], Please note : one is email and other is contact_email