博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php创建验证码_使用PHP进行简单的用户名创建验证
阅读量:2514 次
发布时间:2019-05-11

本文共 1186 字,大约阅读时间需要 3 分钟。

php创建验证码

When I create login areas (mostly intranets) for small websites, I'm always asked by the customer to keep usernames to letters and numbers. That means no email addresses as usernames and special characters like "_", "-", and ".". This, in my customer's mind, keeps the login easy for their users and limits the number of support calls they will receive. While I don't recommend disallowing common username characters like the ones cited above, I do understand their need for simplicity. Here's how, using PHP, I validate that a username is only letters and numbers.

当我为小型网站创建登录区域(主要是内部网)时,客户总是要求我将用户名保留为字母和数字。 这意味着没有电子邮件地址作为用户名和特殊字符(如“ _”,“-”和“。”)。 在我的客户看来,这使他们的用户易于登录,并限制了他们将收到的支持电话的数量。 尽管我不建议您禁止使用上述常见的用户名字符,但我确实理解它们对简单性的需求。 使用PHP验证用户名只是字母和数字的方法如下。

PHP (The PHP)

function validate_username($input,$pattern = '[^A-Za-z0-9]'){	return !ereg($pattern,$input);}

It's as easy as that. I don't go as far as using this for passwords, but you could if you wanted to. I'll also mention that if I want to allow non-alphanumeric characters, I just need to change the function's pattern. Easy enough!

就这么简单。 我不打算将其用作密码,但是如果您愿意,可以这样做。 我还要提到,如果要允许使用非字母数字字符,则只需要更改函数的模式即可。 很简单!

翻译自:

php创建验证码

转载地址:http://qppwd.baihongyu.com/

你可能感兴趣的文章
剑指offer-二叉树中和为某一值的路径
查看>>
Java反射机制
查看>>
Python 正则表达式
查看>>
C++ AppendMenu
查看>>
在所选中的物体中取消选中一些物体.txt
查看>>
grid - 网格项目跨行或跨列
查看>>
Shell 基本运算符
查看>>
2019年2月
查看>>
Google Noto Sans CJK 字体
查看>>
ES集群性能调优链接汇总
查看>>
STL库的应用
查看>>
spark算子
查看>>
(转)Linux服务器SNMP常用OID
查看>>
zoj2112 主席树动态第k大 ( 参考资料链接)
查看>>
弹出框popupWindow
查看>>
Python学习(007)-函数的特性
查看>>
扑克牌的顺子
查看>>
nodejs + express 热更新
查看>>
ClientScriptManager.RegisterClientScriptBlock Method 无效
查看>>
asp.net web site中reference的version的autoupdate
查看>>