0

Error on the first line Undefined index: $pwd Also undefined variable Under it. Please show new code Thanks! The ending of it spits out.

$pwd = $_POST['$pwd'];              //Error undefined index: $pwd

if( strlen($pwd) < 8 ) {
        $error .= "Password too short! 
";
}                                     //This line undefined variable

Getting error above here******error variable

if( strlen($pwd) > 20 ) {
        $error .= "Password too long! 
";
}

if( strlen($pwd) < 8 ) {
        $error .= "Password too short! 
";
}

if( !preg_match("#[0-9]+#", $pwd) ) {
        $error .= "Password must include at least one number! 
";
}


if( !preg_match("#[a-z]+#", $pwd) ) {
        $error .= "Password must include at least one letter! 
";
}


if( !preg_match("#[A-Z]+#", $pwd) ) {
        $error .= "Password must include at least one CAPS! 
";
}



if( !preg_match("#\W+#", $pwd) ) {
        $error .= "Password must include at least one symbol! 
";
}


if($error){
        echo "Password validation failure(your choice is weak): $error";
} else {
        echo "Your password is strong.";
}

Thanks again :D

Tony Reed
  • 1
  • 1

3 Answers3

0

Instead of $pwd = $_POST['$pwd']; use $pwd = $_POST['pwd'];

n-dru
  • 9,285
  • 2
  • 29
  • 42
  • Still getting the same index error and the undefined variable. – Tony Reed Feb 24 '15 at 11:06
  • 1
    Then maybe your password input name is not 'pwd'? Check what is in your $_POST array - print_r($_POST); - one of the keys in that array will be your input password name. – n-dru Feb 24 '15 at 11:08
0

$pwd = $_POST['$pwd'];

I guess this is meant to be:

$pwd = $_POST['pwd'];

But it depends on what name the password field have in your form. If the name of the password field on the form is password, then make it $_POST['password']

Jesper
  • 3,816
  • 2
  • 16
  • 24
0

if you have...

<input type="password" name="pwd">

then in your php script, you should call it

$pwd = $_POST["pwd"];

take note of the name attribute.

Ray Lionfang
  • 689
  • 6
  • 17