]> git.p6c8.net - form-email.git/blobdiff - form-email/mailer.php
Pruefung ob indiv. Feld gesetzt wurde, funktioniert.
[form-email.git] / form-email / mailer.php
index c85d2062320e185696910c546e45936604d9a675..52e3110305c00e306a8f7c0477926dfcad14bbb1 100644 (file)
@@ -96,15 +96,23 @@ $prepared_user_fields = array();
 \r
 while(list($user_field,$user_field_data) = each($user_fields)) {\r
     $user_field_content = formdata($user_field);\r
+    \r
+    if((!$user_field_data['optional']) && (!$user_field_content)) {\r
+        show_user_error($user_field_data['errors']['not_set']);\r
+    }\r
+    elseif($user_field_data['optional'] && (!$user_field_content)) {\r
+        $prepared_user_fields[$user_field_data['tpl_var']] = '';\r
+        continue;\r
+    }\r
 \r
     if(isset($user_field_data['check']) && $user_field_data['check'] != '') {\r
-        if(function_exists($user_field_data['check']) && call_user_func($user_field_data['check'],$user_field_content)) {\r
+        if(function_exists($user_field_data['check']) && call_user_func($user_field_data['check'],$user_field_content) === false) {\r
             show_user_error($user_field_data['errors']['check_fail']);\r
         }\r
     }\r
 \r
     if(isset($user_field_data['regex']) && $user_field_data['regex'] != '') {\r
-        if(preg_match($user_field_data['regex'],$user_field_content)) {\r
+        if(!preg_match($user_field_data['regex'],$user_field_content)) {\r
             show_user_error($user_field_data['errors']['match_fail']);\r
         }\r
     }\r

patrick-canterino.de