Advertisement
Guest User

Untitled

a guest
Apr 15th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <?php
  2. require_once 'include/db_functions.php';
  3. $db = new DB_Functions();
  4.  
  5. // json response array
  6. $response = array("error" => FALSE);
  7.  
  8. if (isset($_POST['email']) && isset($_POST['password'])) {
  9.  
  10. // receiving the post params
  11. $email = $_POST['email'];
  12. $password = $_POST['password'];
  13.  
  14. // get the user by email and password
  15. $user = $db->getUserByEmailAndPassword($email, $password);
  16.  
  17. if ($user != false) {
  18. // use is found
  19. $response["error"] = FALSE;
  20. $response["uid"] = $user["unique_id"];
  21. $response["user"]["first_name"] = $user["firstname"];
  22. $response["user"]["last_name"] = $user["lastname"];
  23. $response["user"]["email"] = $user["email"];
  24. $response["user"]["date_of_birth"] = $user["dateofbirth"];
  25. $response["user"]["sex"] = $user["sex"];
  26. $response["user"]["created_at"] = $user["created_at"];
  27. $response["user"]["updated_at"] = $user["updated_at"];
  28. echo json_encode($response);
  29. } else {
  30. // user is not found with the credentials
  31. $response["error"] = TRUE;
  32. $response["error_msg"] = "Login credentials are wrong. Please try again!";
  33. echo json_encode($response);
  34. }
  35. } else {
  36. // required post params is missing
  37. $response["error"] = TRUE;
  38. $response["error_msg"] = "Required parameters email or password is missing!";
  39. echo json_encode($response);
  40. }?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement