public function processAction() { if (isset($_POST['programName'], $_POST['duration'], $_POST['directorId'])) { $_POST['directorId'] = (int) $_POST['directorId']; $_POST['programName'] = strip_tags($_POST['programName']); $_POST['duration'] = strip_tags($_POST['duration']); $dto = new ProgramDTO(); $dao = new ProgramDAO(); $dto->hydrate($_POST); // id = -1 if you come from the insert form if (-1 == $_POST['id']) { $dao->insert($dto); } else { $dao->update($dto); } } header('Location: index.php?ctrl=program&act=indexProg'); }