protected function createexam() { $required = array("name" => "Examination Name", "start_date" => "Start Date", "end_date" => "End Date", "fn_an" => "Sessions"); global $user; if ($user->checkAdmin() == true) { if (isset($_POST)) { foreach ($required as $key => $value) { if (!isset($_POST[$key]) || $_POST[$key] == '' || $_POST[$key] == 'select') { echo $value . ' is Required<br/>'; return; } } echo 'Saving...'; global $objPDO; require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/examination_class.php'; $exam = new Examination($objPDO); $exam->setName($_POST['name']); $exam->setStartDate(date('Y-m-d H:i:s T', strtotime($_POST['start_date']))); $exam->setEndDate(date('Y-m-d H:i:s T', strtotime($_POST['end_date']))); $exam->setFnAn($_POST['fn_an']); $exam->save(); echo '<meta http-equiv="Refresh" content="0;url=http://localhost/cloud/examination/selectsubjects"/>'; } } else { header('Location:http://localhost/cloud'); } }