dimanche 31 janvier 2021

php checking if password is valid problem

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:

  1. The password must be at least 6 characters and at most 20 characters.
  2. It must contain at least one lowercase letter, one uppercase letter and one number.
  3. 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