0

I would like to be sure that the email address somebody enters into my form isn't from a free email provider such as gmail, hotmail/live, yahoo, etc.

How would I do that? I know the FILTER_VALIDATE_EMAIL option doesn't work for this.

4

1 回答 1

2

Like this:

$email_address = 'test@hotmail.com';
$not_allowed = array('hotmail.com', 'gmail.com', 'msn.ca');
$email = explode('@', $email_address);

if(in_array($email[1], $not_allowed)){
    echo 'Email not allowed';
}else{
    echo 'Email is good';
}
于 2012-12-08T07:24:23.907 回答