我正在尝试为必填字段显示错误消息,但它只是重定向到如果输入某些内容应该转到的页面(我将其留空)
$required_fields = array('NativeLanguage');
foreach ($required_fields as $val) {
while (is_array($val))
$val = reset($val);
if (!empty($_POST[$val])) {
$val = trim($_POST[$val]);
}
else {
$err[] = "ERROR - $val is required";
}
}