Sign Up

welcome

Already have an account? Sign In

Sign In

welcome

Sign Up
Login with Google

Don't have account, Sign Up Here
Sign In Sign Up

letsrectify

letsrectify
  • Home
  • About Us
  • Contact Us
  • Jobs
Ask a Question
Home
Jaskaran Singh
Asked: 02-04-22

How to assure password quality in php ?

  • 3

Try following script ➡️➡

      $errors = array();

      if (strlen($pass) < 8 || strlen($pass) > 16) {

          $errors[] = "Password should be min 8 characters and max 16 characters";

      }

      if (!preg_match("/\d/", $pass)) {

          $errors[] = "Password should contain at least one digit";

      }

      if (!preg_match("/[A-Z]/", $pass)) {

          $errors[] = "Password should contain at least one Capital Letter";

      }

      if (!preg_match("/[a-z]/", $pass)) {

          $errors[] = "Password should contain at least one small Letter";

      }

      if (!preg_match("/\W/", $pass)) {

          $errors[] = "Password should contain at least one special character";

      }

      if (preg_match("/\s/", $pass)) {

          $errors[] = "Password should not contain any white space";

      }


 

      if ($errors) {

          foreach ($errors as $error) {

              echo "<div class='alert alert-danger'>".$error."</div>";

          }

        $error = 1;

      } else {

        $error = 0;

      }

Share
  • Facebook

0 More Answers

  • Answers
Cancel reply

Sidebar

Ask A Question
letsrectify

Categories

  • Technology
  • Food
  • Health
  • Sports
  • Science
  • Politics
  • Marketing

Policies

  • Terms & Conditions
  • Privacy Policy

About Us

  • About Us
  • Contact Us
  • Feedback

© 2025 All Rights Reserved by
Letsrectify.com