Advertisement
Guest User

Untitled

a guest
Apr 18th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. <?php
  2.  
  3. require_once 'include/db_functions.php';
  4. $db = new db_functions();
  5.  
  6. // json response array
  7. $response = array("error" => FALSE);
  8.  
  9. if (isset($_POST['user_login']) && isset($_POST['user_password']) && isset($_POST['user_name']) && isset($_POST['user_middle_name']) && isset($_POST['user_last_name']) && isset($_POST['user_group'])) {
  10.  
  11. // receiving the post params
  12. $user_login = $_POST['user_login'];
  13. $password = $_POST['user_password'];
  14. $user_name = $_POST['user_name'];
  15. $user_middle_name = $_POST['user_middle_name'];
  16. $user_last_name = $_POST['user_last_name'];
  17. $user_group = $_POST['user_group'];
  18.  
  19. // check if user is already existed with the same login
  20. if ($db->isUserExisted($user_login)) {
  21. // user already existed
  22. $response["error"] = TRUE;
  23. $response["error_msg"] = "User " . $user_login . " already exists";
  24. echo json_encode($response);
  25. } else {
  26. // create a new user
  27. $user = $db->storeUser($user_login, $password, $user_name, $user_middle_name, $user_last_name, $user_group);
  28. if ($user) {
  29.  
  30. **ОШИБКА ПРОИСХОДИТ ЗДЕСЬ, ВО ВСЕХ СЛЕДУЮЩИХ ПОЛЯХ $response**
  31.  
  32. $response["error"] = FALSE;
  33. $response["uid"] = $user["user_uniqueid"];
  34. $response["user"]["user_login"] = $user["user_login"];
  35. $response["user"]["user_name"] = $user["user_name"];
  36. $response["user"]["user_middle_name"] = $user["user_middle_name"];
  37. $response["user"]["created_at"] = $user["created_at"];
  38. echo json_encode($response);
  39. } else {
  40. // user failed to store
  41. $response["error"] = TRUE;
  42. $response["error_msg"] = "Failed to store";
  43. echo json_encode($response);
  44. }
  45. }
  46. } else {
  47. $response["error"] = TRUE;
  48. $response["error_msg"] = "Fill up all fields!";
  49. echo json_encode($response);
  50. }
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement