Codeigniter 自定义电子邮件验证规则
有人可以提供一些关于如何为 Codeigniter 创建自定义验证规则的建议吗?
我正在开发的网站是针对大学生的,仅允许用户使用大学电子邮件地址进行注册。
以下是我试图实现的验证类型的示例:
仅允许以以下内容结尾的电子邮件:
array(
'0' => '@uni-email-1.com',
'1' => '@uni-email-2.com',
'2' => '@uni-email-3.com',
'3' => '@uni-email-4.com',
);
我对 codeigniter 仍然很陌生,并且不确定如何创建这种类型的验证。
非常感谢任何帮助!
谢谢
Can someone please provide some advise on how to go about creating custom validation rules for Codeigniter.
The website I am working on is for university students and only allows users to register if they use their university email address.
Here is an example of the type of validation I am trying to achieve:
Only allow emails that end with:
array(
'0' => '@uni-email-1.com',
'1' => '@uni-email-2.com',
'2' => '@uni-email-3.com',
'3' => '@uni-email-4.com',
);
I am still quite new to codeigniter and I am not sure how to create this type of validation.
Any assistance is very much appreciated!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
当然可以,这个怎么样?
Sure, how's this?
这实际上与 PHP 的关系比与 CI 的关系更大。基本上,您应该将插入的电子邮件地址与您提供的每个结束字符串进行字符串匹配。如果存在匹配 - 允许注册,如果不匹配 - 输出警报或其他内容并且不允许注册。
This is actually more related to PHP than CI. Basically, you should string match inserted email address to each ending string you provided. If there is a match - allow registering, if not - output an alert or something and don't allow it.
如果您的大学有 LDAP 目录,那么您可以通过它进行身份验证,而不需要使用另一个基地。单点登录是一个非常适合在大学等机构中使用的系统
If your university has an LDAP directory, then you can do authentication over it, instead of having another base. Single Sign On is a very good system for use in institutions such as universities
尝试以下类似的方法,
希望有帮助
Try something like following,
Hope it helps
html5 简单代码来验证电子邮件
您可以通过带有模式的
You can validate email by html5 simple code
with pattern