问题
i want only my corporate people to sign up , who've got E.G abc@ourcompany.com emails and not other people like abc@gmail.com or abc@outlook.co etc.
i'm not able to post my code here . i've posted it here , pls check and help http://pastebin.com/0aJZfHWx
回答1:
$allowed_domains = array("ourcompany.com");
$email_domain = array_pop(explode("@", $email));
if(!in_array($email_domain, $allowed_domains)) {
// Not an authorised email
}
It's simply. Make an array for allowed domains, explode by @
, get the last element of the array and check if it exists in the allowed domains array.
来源:https://stackoverflow.com/questions/26454353/how-do-i-allow-only-specific-domain-email-to-sign-up-on-my-micro-blog