Guest User

Untitled

a guest
Aug 20th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <?php
  2. require_once 'db_function.php';
  3. $db = new DB_Functions; //define in db_function.php line 5
  4. //json response
  5. $response = array("error"=>FALSE);
  6.  
  7. if (isset($_POST['email']) && isset($_POST['password']))
  8. {
  9.  
  10. //receiving the post ( parameter )
  11. $email = $_POST['email'];
  12. $password = $_POST['password'];
  13.  
  14. //getUserByEmailAndPassword
  15. $user = $db->getUserByEmailAndPassword($email,$password);
  16. if ($user != false) {
  17.  
  18. //user has found
  19. $response["error"]= FALSE;
  20. $response["uid"] = $user["unique_id"];
  21. $response["user"] ["name"] = $user["name"];
  22. $response["user"] ["email"] = $user["email"];
  23. $response["user"] ["created_at"] = $user["created_at"];
  24. $response["user"] ["updated_at"] = $user["updated_at"];
  25. echo json_encode($response);
  26. }
  27. else{
  28. //user not found or mail is wrong
  29. $response["error"]= TRUE;
  30. $response["error_msg"]= "Login information are wrong. Please try again";
  31. echo json_encode($response);
  32. }
  33. }
  34. else
  35. {
  36. $response["error"] = TRUE;
  37. $response["error_msg"] = "Required parameter (name,email,password) is missing";
  38. echo json_encode($response);
  39. }
  40. ?>
Add Comment
Please, Sign In to add comment