How do i allow only specific domain email to sign up on my micro blog [closed]

六眼飞鱼酱① 提交于 2019-12-13 11:28:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!