Esempio n. 1
0
         $response["user"]["name"] = $user["name"];
         $response["user"]["created_at"] = $user["created_at"];
         $response["user"]["updated_at"] = $user["updated_at"];
         $response["user"]["Student_ID"] = $user["Student_ID"];
         echo json_encode($response);
     } else {
         $response["error"] = TRUE;
         $response["error_msg"] = "Incorrect Student ID or password";
         echo json_encode($response);
     }
 } else {
     if ($tag == 'register') {
         $name = $_POST['name'];
         $Student_ID = $_POST['Student_ID'];
         $password = $_POST['password'];
         if ($db->isUserExisted($Student_ID)) {
             $response["error"] = TRUE;
             $response["error_msg"] = "User already exist";
             echo json_encode($response);
         } else {
             $user = $db->storeUser($name, $Student_ID, $password);
             if ($user) {
                 $response["error"] = FALSE;
                 $response["uid"] = $user["unique_id"];
                 $response["user"]["name"] = $user["name"];
                 $response["user"]["created_at"] = $user["created_at"];
                 $response["user"]["updated_at"] = $user["updated_at"];
                 $response["user"]["Student_ID"] = $user["Student_ID"];
                 echo json_encode($response);
             } else {
                 $response["error"] = TRUE;