如何限制用PHP注册的公共电子邮件ID? [英] How to restrict public email id for registration in PHP?
问题描述
由于您没有提供任何其他信息使用PHP的 preg_match()
函数以及$ code提交以下内容,以及如何定义和/或输入表单? > b 和 i
模式分隔符和数组。
b
- 字边界
i
- 不区分大小写
以下将与Gmail或Gmail等匹配有人想欺骗系统。
包括Hotmail,Yahoo。您可以添加到数组。
<?php
$ _POST ['email'] =email @ Gmail.com;
$ data = $ _POST ['email'];
if(preg_match(/ \b(hotmail | gmail | yahoo)\b / i,$ data)){
echo找到免费电子邮件服务。
退出;
}
else {
echo找不到免费电子邮件服务的匹配项。
退出;
}
其实可以使用如果(preg_match(/(hotmail | gmail | yahoo)/ i,$ data))
而不是:
if(preg_match(/ \b(hotmail | gmail | yahoo)\b / i,$ data))
其结果相同。
I have a registration form that uses any kind of emails for registration. I want to restrict it to company mail id's only. In other words, no free email service provider's mail id would work for registration.
Since you have not provided any additional information as to how E-mail addresses are being defined and/or entered into a form or not, am submitting the following using PHP's preg_match()
function, along with b
and i
pattern delimiters and an array.
b
- word boundary
i
- case insensitive
The following will match against "gmail" or "Gmail" etc. should someone want to trick the system.
Including Hotmail, Yahoo. You can add to the array.
<?php
$_POST['email'] = "email@Gmail.com";
$data = $_POST['email'];
if(preg_match("/\b(hotmail|gmail|yahoo)\b/i", $data)){
echo " Found free Email service.";
exit;
}
else{
echo "No match found for free Email service.";
exit;
}
Actually, you can use:
if(preg_match("/(hotmail|gmail|yahoo)/i", $data))
instead of:
if(preg_match("/\b(hotmail|gmail|yahoo)\b/i", $data))
which gave the same results.
这篇关于如何限制用PHP注册的公共电子邮件ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!