X-Git-Url: https://git.p6c8.net/form-email.git/blobdiff_plain/f1f62b07946e764d3b51d1da4eeb7aa83702bec6..6f125a20df39454f1f785075998d0c0751055ba5:/form-email/mailer.php diff --git a/form-email/mailer.php b/form-email/mailer.php index c85d206..52e3110 100644 --- a/form-email/mailer.php +++ b/form-email/mailer.php @@ -96,15 +96,23 @@ $prepared_user_fields = array(); while(list($user_field,$user_field_data) = each($user_fields)) { $user_field_content = formdata($user_field); + + if((!$user_field_data['optional']) && (!$user_field_content)) { + show_user_error($user_field_data['errors']['not_set']); + } + elseif($user_field_data['optional'] && (!$user_field_content)) { + $prepared_user_fields[$user_field_data['tpl_var']] = ''; + continue; + } if(isset($user_field_data['check']) && $user_field_data['check'] != '') { - if(function_exists($user_field_data['check']) && call_user_func($user_field_data['check'],$user_field_content)) { + if(function_exists($user_field_data['check']) && call_user_func($user_field_data['check'],$user_field_content) === false) { show_user_error($user_field_data['errors']['check_fail']); } } if(isset($user_field_data['regex']) && $user_field_data['regex'] != '') { - if(preg_match($user_field_data['regex'],$user_field_content)) { + if(!preg_match($user_field_data['regex'],$user_field_content)) { show_user_error($user_field_data['errors']['match_fail']); } }