'."\n"; foreach ($f['controls'] as $c) { if (isset($c['type']) && $c['type'] == 'hidden') { $out .= ''."\n"; } else { $out .= ''."\n"; if (isset($c['maxlength'])) $maxlength = ' maxlength="'.$c['maxlength'].'"'; $val = ''; if (isset($value[$c['name']])) $val = entenc($value[$c['name']]); $out .= ''."\n"; } } $out .= "
'; if ($c['required']) $out .= '*'; if (isset($msg[$c['name']])) $out .= ''.entenc($msg[$c['name']]).''; $out .= '
\n"; if ($f['submit']) $out .= ''."\n"; $out .= "\n"; return $out; } function validate_form_date($date) { if (!is_date($date)) return 'ongeldige datum'; return false; } function validate_form_email($email) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) return 'ongeldig emailadres'; return false; } function validate_form($f, &$out) { foreach ($f['controls'] as $c) { if (!isset($_POST[$c['name']])) internal_error('field '.$c['name'].' missing from POST data'); if ($_POST[$c['name']] == '') { if ($c['required']) $error['msg'][$c['name']] = 'mag niet leeg zijn'; continue; } $error['value'][$c['name']] = $_POST[$c['name']]; if (isset($c['validator']) && ($msg = $c['validator']($_POST[$c['name']]))) { $error['msg'][$c['name']] = $msg; continue; } if (isset($c['pp'])) $out[$c['name']] = $c['pp']($_POST[$c['name']]); else $out[$c['name']] = $_POST[$c['name']]; if (isset($c['pp_maxlength']) && strlen($out[$c['name']]) > $c['pp_maxlength']) { $error['msg'][$c['name']] = 'input te lang, max is '.$c['maxlength'].' bytes'; continue; } } if (isset($error['msg'])) { header('Location: '.$f['name'].'?error='.urlencode(enc_signed_data($error))); exit; } return $error; } ?>