array_push($errorArr, "Please enter {$postVar} ");
                 }
                 break;
             default:
                 $coursBrochObj->{$postVar} = filter_input(INPUT_POST, $postVar) ? mysqli_real_escape_string($dbObj->connection, filter_input(INPUT_POST, $postVar)) : '';
                 if ($coursBrochObj->{$postVar} === "") {
                     array_push($errorArr, "Please enter {$postVar} ");
                 }
                 break;
         }
     }
     if (count($errorArr) < 1) {
         if ($coursBrochDoc != '' && file_exists(MEDIA_FILES_PATH . "brochure/" . $coursBrochDoc)) {
             unlink(MEDIA_FILES_PATH . "brochure/" . $coursBrochDoc);
         }
         echo $coursBrochObj->delete();
     } 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, "addNewBrochure") != NULL && filter_input(INPUT_POST, "addNewBrochure") == "editCourseBrochure") {
     $postVars = array('id', 'name', 'document');
     // Form fields names
     $oldDocument = $_REQUEST['oldFile'];
     //Validate the POST variables and add up to error message if empty
     foreach ($postVars as $postVar) {
         switch ($postVar) {