function session_validate_form_set($form_vars, $redirect_page = null)
{
    $required_field_empty = false;
    if (empty($form_vars) && $redirect_page) {
        error_report_show($redirect_page, REQUIRED_FIELD_MISSING);
    } else {
        //$_SESSION['validate_form'] = array();
        foreach ($form_vars as $key => $value) {
            # for multiple select
            if (is_array($value)) {
                $_SESSION['validate_form'][$key] = $value;
                # when not a multiple select
            } else {
                //$value = htmlspecialchars($value, ENT_QUOTES);
                $value = util_strip_slashes($value);
                $_SESSION['validate_form'][$key] = $value;
                $trimmed_value = trim($value);
                if (strpos($key, '_required') && empty($trimmed_value)) {
                    $required_field_empty = true;
                }
            }
        }
        if ($required_field_empty && $redirect_page) {
            error_report_show($redirect_page, REQUIRED_FIELD_MISSING);
        }
    }
}
예제 #2
0
function util_html_special_chars_string($str)
{
    return htmlspecialchars(util_strip_slashes($str), ENT_QUOTES);
}