Peter Helao
Peter Helao

Reputation: 3

Password match says they don't match when they really do

When entering data it tells password do not match even if they are. What could be wrong with my password confirmation?

if ($_POST['password'] == $_POST ['cpassword']){
    array_push($errors, "The two passwords do not match");
}

I have tried using the $_POST on password and $_GET on the cpassword and I also tried $_GET method on both but to no avail.

Upvotes: 0

Views: 546

Answers (1)

FreedomPride
FreedomPride

Reputation: 1102

if ($_POST['password'] == $_POST['cpassword']){
   array_push($errors, "The two passwords do not match");
}

It check that if password equals (==) cpassword, you're throwing the error The two passwords do not match. So you are probably doing the opposite of what you want to do. Use the !== operator to check if they are not equal.

TLDR; Password == Cpassword , you're giving error do no match even they both matches

Hopefully this enlighten you.

Upvotes: 1

Related Questions