没有检查上述领域。 两种版本
第一版:
$error = array();
$field_sets = array( username , password , fullname , repeatpass , email );
foreach($field_sets as $fieldname){
if (!isset($_POST[$fieldname]) || (empty($_POST[$fieldname]) && $_POST[$fieldname] != 0)) {
$error[] = $fieldname;
}
}
第二版:
(in the includes file)
function check_required_fields ($required_array){
$error = array();
foreach($required_array as $fieldname){
if (!isset($_POST[$fieldname]) || (empty($_POST[$fieldname]) && $_POST[$fieldname] != 0)) {
$error[] = $fieldname;
}
}
return $error;
}
In the Source File:
$error = array();
$required_field = array( username , password , fullname , repeatpass , email );
$error = array_merge($error , check_required_fields($required_field , $_POST));