$tutorObj->{$postVar} = 0; } elseif ($tutorObj->{$postVar} == 0) { $tutorObj->{$postVar} = 1; } break; default: $tutorObj->{$postVar} = filter_input(INPUT_GET, $postVar) ? mysqli_real_escape_string($dbObj->connection, filter_input(INPUT_GET, $postVar)) : ''; if ($tutorObj->{$postVar} === "") { array_push($errorArr, "Please enter {$postVar} "); } break; } } //If validated and not empty submit it to database if (count($errorArr) < 1) { echo Tutor::updateSingle($dbObj, ' visible ', $tutorObj->visible, $tutorObj->id); } else { $json = array("status" => 0, "msg" => $errorArr); $dbObj->close(); //Close Database Connection header('Content-type: application/json'); echo json_encode($json); } } if (filter_input(INPUT_POST, "updateThisTutor") != NULL) { $postVars = array('id', 'name', 'qualification', 'field', 'bio', 'email', 'website', 'picture'); // Form fields names $oldPicture = $_REQUEST['oldPicture']; //Validate the POST variables and add up to error message if empty foreach ($postVars as $postVar) { switch ($postVar) {