I need to write a function in php that checks if a password is valid.
Function would return True if the following conditions are met:
- The password must be at least 6 characters and at most 20 characters.
- It must contain at least one lowercase letter, one uppercase letter and one number.
- Otherwise, it returns False.
So far, this is the code I have (not too sure how to incorporate the second condition into the code after &&)...
<?php
function isValid($password){
if((strlen($password)>= 6 && strlen($password)<= 20) && ){
}
}
?>
Could someone show me how to complete my code in 2 ways? One without using preg_match() and the other with preg_match()?
Aucun commentaire:
Enregistrer un commentaire