我正在为php学校项目工作我有2个文件,checkBlank.php和form.php。一切都正确显示并且提交表单很好,但它没有显示未填写的字段的echo $消息。
以下是代码:
if(isset($_POST['submitted']) and $_POST['submitted'] == 'yes') {
foreach($_POST as $field => $value) {
if(empty($value)) {
$blank_array[] = $field;
}
else {
$good_data[$field] = strip_tags(trim($value));
}
}
if(@sizeof($blank_array) > 0) {
$message = "<p style ='color: red; margin-bottom: 0; font-weight: bold'>
You have not filled in all the fields.
Please fill in the:
<ul style='color: red; margin-top: 0; list-style: none' >";
foreach($blank_array as $value) {
$message .= "<li>$value</li>";
}
$message .= "</ul>";
echo $message;
extract($good_data);
include ("form.inc");
exit();
}
echo "All fields contain information";
}
else {
include("form.inc");
}