Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'include/db_functions.php';
- $db = new db_functions();
- // json response array
- $response = array("error" => FALSE);
- 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'])) {
- // receiving the post params
- $user_login = $_POST['user_login'];
- $password = $_POST['user_password'];
- $user_name = $_POST['user_name'];
- $user_middle_name = $_POST['user_middle_name'];
- $user_last_name = $_POST['user_last_name'];
- $user_group = $_POST['user_group'];
- // check if user is already existed with the same login
- if ($db->isUserExisted($user_login)) {
- // user already existed
- $response["error"] = TRUE;
- $response["error_msg"] = "User " . $user_login . " already exists";
- echo json_encode($response);
- } else {
- // create a new user
- $user = $db->storeUser($user_login, $password, $user_name, $user_middle_name, $user_last_name, $user_group);
- if ($user) {
- **ОШИБКА ПРОИСХОДИТ ЗДЕСЬ, ВО ВСЕХ СЛЕДУЮЩИХ ПОЛЯХ $response**
- $response["error"] = FALSE;
- $response["uid"] = $user["user_uniqueid"];
- $response["user"]["user_login"] = $user["user_login"];
- $response["user"]["user_name"] = $user["user_name"];
- $response["user"]["user_middle_name"] = $user["user_middle_name"];
- $response["user"]["created_at"] = $user["created_at"];
- echo json_encode($response);
- } else {
- // user failed to store
- $response["error"] = TRUE;
- $response["error_msg"] = "Failed to store";
- echo json_encode($response);
- }
- }
- } else {
- $response["error"] = TRUE;
- $response["error_msg"] = "Fill up all fields!";
- echo json_encode($response);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement