Ejemplo n.º 1
0
     }
 } else {
     if ($tag == 'register') {
         // Request type is Register new user
         $pseudo = $_POST['pseudo'];
         $email = $_POST['email'];
         $password = $_POST['password'];
         // check if user is already existed
         if ($db->isUserExisted($pseudo, $email)) {
             // user is already existed - error response
             $response["error"] = TRUE;
             $response["error_msg"] = "Pseudo ou email éxiste déjà";
             echo json_encode($response);
         } else {
             // store user
             $user = $db->storeUser($pseudo, $email, $password);
             if ($user) {
                 // user stored successfully
                 $response["error"] = FALSE;
                 // $response["uid"] = $user["unique_id"];
                 $response["utilisateur"]["pseudo"] = $user["pseudo"];
                 $response["utilisateur"]["email"] = $user["email"];
                 $response["utilisateur"]["password"] = $user["password"];
                 // $response["user"]["created_at"] = $user["created_at"];
                 //$response["user"]["updated_at"] = $user["updated_at"];
                 echo json_encode($response);
             } else {
                 // user failed to store
                 $response["error"] = TRUE;
                 $response["error_msg"] = "Error occured in Registartion";
                 echo json_encode($response);