$app->post(’/api/login’, function($request, $response) {
$email= $request->getParam(‘email’);
$pass= $request->getParam(‘pass’);
try
{
//get db object
$db = new db();
//connect
$db = $db->connect();
$sth = $db->prepare(“SELECT count(*) AS count FROM users WHERE email=:email AND password=:pass”);
$sth->bindParam(’:pass’, $pass);
$sth->bindParam(’:email’, $email);
$sth->execute();
$row = $sth->fetch();
if($row[‘count’]>0){
$output = array(
‘status’=>“1”,
‘login’=>“sucess”,
);
}
else{
$output = array(
‘status’=>“0”,
‘login’=>“fail”,
);
}
}
catch(Exception $ex){
$output = array(
‘status’=>“2”,
‘login’=>“error”,
);
}
// $object = (object) $output;
echo json_encode($output);
$db = null;
});