So, I have a collection called: ‘members’ and in that I have a user name and password for each of my ‘members’.
What I need to know is how do I check to see if the two match i.e. username + password = success
This is what I have tried and it does the search correctly, just it’s not returning the error if no user
public function userlogin($data)
{
$this->data = $data;
$collection = $this->db->members;
// find everything in the collection
$cursor = $collection->find(array("username"=>$this->data['username'], "password"=>$this->data['password']));
$test = array();
// iterate through the results
while( $cursor->hasNext() ) {
$test[] = ($cursor->getNext());
}
//Print Results
if($test == NULL)
{
print "Sorry we are not able to find you";
die;
}
//print json_encode($test);
}
Something like this:
Or: