脚本宝典收集整理的这篇文章主要介绍了php – Codeigniter自定义电子邮件验证规则,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在研究的网站是针对大学生的,只允许用户在使用他们的大学电子邮件地址时进行注册.
以下是我尝试实现的验证类型的示例:
仅允许以以下结尾的电子邮件:
array( '0' => '@uni-email-1.COM','1' => '@uni-email-2.com','2' => '@uni-email-3.com','3' => '@uni-email-4.com',);
我仍然是codeigniter的新手,我不知道如何创建这种类型的验证.
非常感谢任何帮助!
谢谢
function index() { $this->load->helPEr(array('form','url')); $this->load->library('form_validation'); $this->form_validation->set_rules('email','Email','required'); $this->form_validation->set_rules('email','valid_email'); $this->form_validation->set_rules('email','callback_email_check'); if ($this->form_validation->run() == FALSE) { //fail } else { //success } } function email_check($str) { if (stristr($str,'@uni-email-1.com') !== false) return true; if (stristr($str,'@uni-email-2.com') !== false) return true; if (stristr($str,'@uni-email-3.com') !== false) return true; $this->form_validation->set_message('email','Please PRovide an acceptable email address.'); return FALSE; }
以上是脚本宝典为你收集整理的php – Codeigniter自定义电子邮件验证规则全部内容,希望文章能够帮你解决php – Codeigniter自定义电子邮件验证规则所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。