Jump to content

How to check if username and password match in PW?


Juergen
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...