} else { $v->saveToDB(); $trial->addViolation($v); $email = $trial->generateViolationEmail(); $trial->sendEmail($email); $_SESSION['message'] = "Thank you for recording this protocol deviation."; } } else { $_SESSION['error'] = "You must complete the protocol deviation form in its entirety, please try again."; } header("Location:index.php"); exit; } else { $complete = $trial->addUserInput($_POST); if ($page == 'core' && $trial->record->checkDuplicate()) { $_SESSION['error'] = "{$trial->record->getID()} - A patient has already been entered from that centre with that " . Config::get('idName') . "."; $complete = false; } else { $trial->record->saveToDB(); } if ($complete) { $newPage = $trial->getNextPage(); } else { $newPage = $page; } header("Location:dataentry.php?page={$newPage}"); exit; } } } }