我如何只允许特定域的电子邮件在我的微博客上注册 [英] How do i allow only specific domain email to sign up on my micro blog

查看:145
本文介绍了我如何只允许特定域的电子邮件在我的微博客上注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只希望我的公司人员注册,并且收到EG abc@ourcompany.com电子邮件,而不要其他人,例如abc@gmail.com或abc@outlook.co等。

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.

我无法在此处发布我的代码。我已将其发布在这里,请检查并帮助
http://pastebin.com/0aJZfHWx

i'm not able to post my code here . i've posted it here , pls check and help http://pastebin.com/0aJZfHWx

推荐答案

$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.

这篇关于我如何只允许特定域的电子邮件在我的微博客上注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆