Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <?php
  2.  
  3. $data = json_decode(file_get_contents('php://input'), TRUE);
  4.  
  5. if (isset($data['user'])) {
  6.  
  7. require __DIR__ . '/library.php';
  8. $username = (isset($data['user']['username']) ? $data['user']['username'] : NULL);
  9. $password = (isset($data['user']['password']) ? $data['user']['password'] : NULL);
  10.  
  11. // validations
  12. if ($username == NULL) {
  13. http_response_code(400);
  14. echo json_encode(['errors' => ["Username Field is required"]]);
  15.  
  16. }
  17. else if($password==NULL){
  18. http_response_code(400);
  19. echo json_encode(['errors' => ["Password Field is required"]]);
  20. }else {
  21.  
  22. // Update the Task
  23. $user = new user();
  24.  
  25. $user->login($username,$password);
  26. }
  27. }
  28.  
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement