Advertisement
Guest User

Untitled

a guest
Aug 21st, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. $app->get('/login/{username}&{password}', function (Request $request, Response $response) use($app, $pdo) {
  2.  
  3.     $username = $request->getAttribute('username');
  4.     $password = $request->getAttribute('password');
  5.  
  6.     $query = $pdo->select()
  7.         ->from('employee')
  8.         ->where('username', '=', $username)
  9.         ->where('password', '=', md5($password))
  10.         ;
  11.     $stmt = $query->execute();
  12.     $employee = $stmt->fetch();
  13.  
  14.     if($employee) {
  15.         $data = array('status' => $response->getStatusCode(), $employee);
  16.         $data = $response->withJson($data, 201);
  17.     } else {
  18.         $data = array('status' => $response->getStatusCode(), 'message' => 'Employee does not exist');
  19.         $data = $response->withJson($data, 404);
  20.     }
  21.  
  22.     return $data;
  23. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement