}
// handle submit
if (isset($_POST['cancel'])) {
    header('Location: index.php');
    exit;
} else {
    if (isset($_POST['save']) || isset($_POST['save_and_close'])) {
        // check syntax
        $func = $stripslashes(trim($_POST['func']));
        if (!CheckFuncUtility::validateSyntax($func)) {
            $msg->addError('SYNTAX_ERROR');
        }
        // Prevent the php built-in functions and php super global variables
        // being called in the check function. Only allows the AChecker-defined
        // check functions being called for the security concern.
        CheckFuncUtility::validateSecurity($func);
        if (!$msg->containsErrors()) {
            $checksDAO = new ChecksDAO();
            $checksDAO->setFunction($check_id, $func);
            $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
            if (isset($_POST['save_and_close'])) {
                header('Location: index.php');
            } else {
                header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $check_id);
            }
            exit;
        }
    }
}
// end of handle submit
// initialize page