Juergen Posted May 12, 2016 Posted May 12, 2016 Hello @ all, I want to know how to check if username and password match in PW. I need an if condition to get true or false. Here is the code so far: $match = true; $username = $input->get['user']; $pass = $input->get['pass']; $u = $users->get($username); if ($u->id && $u->pass && $u->pass === $pass) { $match = true; } else { //password and username dont match $match = false; } // Finally, return a JSON echo json_encode(array( 'valid' => $match, )); "user" ist the formfield with the username; "pass" is the formfield with the password. This code should output a json string with valid true or false (for Ajax response). Unfortunately this code doesnt work I get always false. Does anybody know how to check the matching?
Juergen Posted May 12, 2016 Author Posted May 12, 2016 Ok I was a little bit too fast with my first entry. Replace if ($u->id && $u->pass && $u->pass === $pass) { with if($u->id && $u->pass->matches($pass)){ and it works
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now