Question

I want to create an system to check some emails from a list, if there are blacklisted or not. More example, I want to create a MySQL table where is put some emails like @gmail.com or @yahoo.com

Now, I want to create a PHP function that check if email is on blacklist, for example on a registration form, user try to join with an email like somebody@yahoo.com, I want to return error, because @yahoo.com is on blacklist. I don't know to explain better, but I think you understand what I want.

Was it helpful?

Solution

//array of blacklisted domains
$domains = //sql call here

foreach($domains as $domain){    
    if(strpos($email, $domain) !== 0)
    {
        //this email is in blacklist
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top