0

i have this function, it is supposed work, to validate if two passwords match

What is problem with this code?

function validatePasswords($myPassword, $pass2) {
    //if DOESN'T MATCH
    if(strpos($myPassword, ' ') !== false)
    return false;

    //if are valid
    return $myPassword == $pass2 && strlen($myPassword) >= 4;
}

thanks :)

7
  • 3
    This function validates that the password: 1: contains no spaces, 2: is at least 4 characters long, and 3: is equal to the second password. What is it supposed to do? Are you sure the problem is in this function? Commented Mar 17, 2011 at 1:17
  • You need to be more specific about what your problem is: "doesn't work" isn't very helpful. An example or two where it doesn't do what you expect would help. Commented Mar 17, 2011 at 1:23
  • 1
    After disabling the Javascript and entering all the form values I get "Congratulations! All fields are OK ;)" so it seems to be working fine. Commented Mar 17, 2011 at 1:27
  • yah anubhava, i change with replace tool the line <input id="myPassword" name="myPassword" type="password" /> and it changes the name myPassword. So the problem is that :) thanks. If you reply, i mark your answer correct Commented Mar 17, 2011 at 1:31
  • @anubhava: What does javascript have to do with it? Commented Mar 17, 2011 at 1:34

1 Answer 1

1

There is no problem with the code you posted.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.