PHP 验证(输入)密码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 验证(输入)密码相关的知识,希望对你有一定的参考价值。

# <?php  
# /* 
# Credits: http://www.bitrepository.com/ 
# */  
#   
# // default chars values are defined  
# function validate_password($password, $min_char = 4, $max_char = 20)  
# {  
# // Remove whitespaces from the beginning and end of a string  
# $password = trim($password);   
#   
# // Accept only letters, numbers and underscore  
# $eregi = eregi_replace('([a-zA-Z0-9_]{'.$min_char.','.$max_char.'})',  
# '', $password);  
#   
# if(empty($eregi))  
#     {  
#     return true;  
#     }  
#     else  
#     {  
#     return false;  
#     }  
# }  
#   
# $password = 'my_password_123';  
#   
# /* 
# First parameter: Password 
# Second parameter: Minimum chars 
# Third parameter: Maximum chars 
# */  
#   
# $validator = validate_password($password, 4, 20);  
#   
# if($validator)  
# {  
# // Our current example will return true  
# echo 'The password is valid.';  
# }  
# else  
# {  
# /* if our password value is for instance: my_@#%_password 
# our function will return false */  
# echo 'The password appears to be invalid.  
# It should contain only letters, numbers and underscore.';  
# }  
# ?>

以上是关于PHP 验证(输入)密码的主要内容,如果未能解决你的问题,请参考以下文章

php form提交账户密码 怎么写验证

php+jQuery+Mysql找回密码----ThinkPHP

如何在 PHP 登录脚本中验证来自 SQL 的串联?

使用 php 和 ajax 进行登录表单验证

在 PHP 中验证密码并确认密码

在PHP中验证密码和确认密码