Hey, so I am new to Slim Framework and PHP aswell, What I am trying to do is to create a route that validates if the user trying to login actually exists, this is what i have so far
$app->post('/login', function ($request, $response, $args) {
$usuario = ($POST['usuario']);
$input = $request->getParsedBody();
$sth = $this->db->prepare("SELECT * FROM aldroges8.oficina_virtual_usuarios WHERE
usuario='".$usuario."'");
$result = $sth->execute();
$row_cnt = $result->num_rows;
if ($row_cnt>0){
return $this->response->withJson(array("ok"=>"acceso autorizado"));
}else{
return $this->response->withJson(array("error"=>"acceso negado"));
}
});
And i tried doing (user in the database) but returns error
curl http://localhost:8080/login -d"usuario=sara"
so anybody can give me a hand on why this is not working?
EDIT:
I did it, i have it now working.
Now i have another question, If I want to add JWT auth, how to I return a token if the user login was successful?