0

Hi,all
I want to ask for the php code to check the password validation?
It couldn't be entire alphabetic or entirely numeric?
Thanks.

4
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by shasha821110
0

Are you asking how to check for only numbers in a string? if so is_numeric would do this:

if (is_numeric($password)) {
        echo "Password is numeric";
     } else {
        echo "Password is not numeric";
   }

Or for alpha-numeric strings:

if (preg_match('/^[A-Za-z0-9]+$/', $password)) {
  // Do something
}
0
if (preg_match('/^[A-Za-z0-9]+$/', $password)) {
  // Do something
}

if i type password: pass123 should work
and i type password should not work correct??

0

here is a regex that will make sure the password has at least 1 uppercase letter, 1 lower case letter, and a number. which is a pretty secure password.

preg_match( "/^.*(?=.{3,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/",$password)
0

Thanks,kkeith29
Here is the code i wrote:

preg_match( "/^.*(?=.*{3,})(?=.*[a-z])(?=.*[A-Z]).*$/",$pass)

But get the warning:

Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 11 in password.php

Any idea about this??
Thanks.
Really new in php

0

no, actually this make my code die.
Which i want is really simple: password must more than 6 characters and should have one number and one alpha
Thanks.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.