$res = $db->addStudent($student_no, $email, $password, $device_id, $course, $status); if ($res != false) { if ($db->addDevices($student_no, $device_id)) { } $stat = $db->updateStatus($student_no, $status); if ($stat) { $res["error"] = FALSE; $res["error_msg"] = "Student status updated"; echo json_encode($res); } else { $res["error"] = TRUE; $res["error_msg"] = "Student status Not updated"; echo json_encode($res); } } else { $res = $db->getStudent($student_no, $password); if ($res != false) { if ($db->addDevices($student_no, $device_id)) { } $stat = $db->updateStatus($student_no, $status); if ($stat) { $res["error"] = FALSE; $res["error_msg"] = "Student status updated"; echo json_encode($res); } else { $res["error"] = TRUE; $res["error_msg"] = "Student status Not updated"; echo json_encode($res); } } else { $res["error"] = TRUE;