我使用tank auth在codeigniter中为电子邮件验证创建了一个回调函数。这是我的代码:
$this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean|valid_email|callback_is_email_domain[gmail.com,yahoo.com]');
function is_email_domain($input, $domain='')
{
$email_domain=explode("@", $input);
$domain = explode(",", $domain);
if(in_array($email_domain[1],$domain))
{
$result=1;
}
else
{
$this->form_validation->set_message('is_email_domain', 'The %s field must be a %s email address');
}
return $result;
}
我希望tank auth只允许'gmail.com'和'yahoo.com'电子邮件在我的网站上注册。
非常感谢你!
答案 0 :(得分:0)
$email_domain is not an array but you have use it as an array `$email_domain[1]`