JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
metaform puts a link to the metaform edit page in the generated php document
[wfpl.git] / metaform / template.php
index 5a5c0ee..07eda6a 100644 (file)
@@ -1,6 +1,12 @@
 <?php
 
-# This form requires wfpl. See: http://jasonwoof.org/wfpl
+# This form requires wfpl. If you didn't recieve wfpl along with this file,
+# see: http://jasonwoof.org/wfpl
+
+# This form was auto-generated. If you would like to alter the parameters and
+# generate a new one try this URL:
+#
+# ~metaform_url~
 
 # This code can send form results by e-mail and/or save them to a database. See
 # the next two comments to enable either or both.
@@ -86,12 +92,18 @@ function ~form_name~() {
                                $message = tem_run('~form_name~.email.txt');
                                $cc = '';
                                $bcc = '';
-                               email($from, $to, $subject, $message, $cc, $bcc);
+                               if(email($from, $to, $subject, $message, $cc, $bcc)) {
+                                       tem_set('error_message', 'Due to an internal error, your message could not be sent. Please try again later.');
+                                       tem_sub('error');
+                                       $error = true;
+                               }
+                       }
+                       if($error !== true) {
+                               tem_load('~form_name~.html');
+                               tem_sub('thankyou');
+                               tem_output();
+                               exit();
                        }
-                       tem_load('~form_name~.html');
-                       tem_sub('thankyou');
-                       tem_output();
-                       exit();
                }
                # otherwise, we display the form again. ~form_name~_get_fields() has
                # already put the posted values back into the template engine, so they will