是否使用变量匹配PRIG_MATCH?
这是我想尝试做的事情。我想要一种简单的方法,只需添加新电子邮件,而不必让我的客户接触主代码。
$list= 'gmail|yahoo|aol';
$banned = '[w.-]+@((?!'.$list.').)[w.-]+.w{2,4}';
if ( isset($data['email']) && !preg_match($banned, $data['email']) )
{}
或者也许。是否包含指向文本文件的内容?其中列出了哪些域?
更新
以下是我的代码..
//Banned Domains
$banned = 'mailexpire|spamtrail|0815';
//
//Emails
$email_list = '/^[w.-]+@((?!'.$banned.').)[w.-]+.w{2,4}$/';
if ( isset($data['email']) && preg_match($email_list, $data['email']) )
{
$response->addError('Email Addresses from this domain are not allowed, Please try a different email address', 'email');
}
else if ( isset($data['email']) && !preg_match($email_list, $data['email']) )
{
$query = SK_MySQL::placeholder("SELECT COUNT(`profile_id`) FROM `".TBL_PROFILE."` WHERE `email`='?'",$data['email']);
if (SK_MySQL::query($query)->fetch_cell()) {
$error_msg = SK_Language::text('%forms._fields.email.errors.already_exists');
$response->addError($error_msg,'email');
}
}
//END
出于某种原因..它没有捕获域?
解决方案
问题是您忘了放模式分隔符:
$banned = '/^[w.-]+@((?!' . $list . ').)[w.-]+.w{2,4}$/';
相关文章