From: Jason Woofenden Date: Thu, 19 Jun 2014 19:15:48 +0000 (-0400) Subject: add contact form X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl-cms.git;a=commitdiff_plain;h=608730c54e00a21b2d2615387e7980dd413eec39 add contact form --- diff --git a/contact.email.txt b/contact.email.txt new file mode 100644 index 0000000..0eaa22c --- /dev/null +++ b/contact.email.txt @@ -0,0 +1,3 @@ +New message from ~name nonempty {~~name~~email nonempty {~ <~email~>~}~~}~~name empty {~~email nonempty {~~email~~}~~email empty {~someone~}~~}~ via your contact form at ~$host~: + +~comments~ diff --git a/contact.html b/contact.html new file mode 100644 index 0000000..11e1fb5 --- /dev/null +++ b/contact.html @@ -0,0 +1,39 @@ + + + + + + <!--~$title show {~-->Messages<!--~}~--> + + + + + + + +

Submit a message

+ +
+ +
Name
+
+ +
Email
+
+ +
Robot Barrier (Required)
+
Enter (below) the number between ~robot_minus_one~ and ~robot_plus_one~
+
+ +
Comments
+
+ +
+
+ +
+ + + + + diff --git a/contact.php b/contact.php new file mode 100644 index 0000000..769b2c5 --- /dev/null +++ b/contact.php @@ -0,0 +1,88 @@ +"; + $reply_to = $to; + if(isset($data['email']) and valid_email($data['email'])) { + $reply_to = $data['email']; + if($data['name'] and ereg('^[a-zA-Z0-9_\' -]*$', $data['name']) !== false) { + $reply_to = "$data[name] <$reply_to>"; + } + } + $subject = "Your message via $host/contact"; + $email_template = new tem(); + $email_template->load('contact.email.txt'); + $email_template->sets($data); + $email_template->set('$host', this_host()); + $message = $email_template->run(); + $cc = ''; + $bcc = ''; + if(email($from, $to, $subject, $message, $reply_to, $cc, $bcc)) { + message('Due to an internal error, your message could not be sent. Please try again later.'); + $error = true; + } else { + message('Message sent'); + } + } + if($error !== true) { + # FIXME create this page or change this to go elsewhere + return './contact_thanks'; + } + } + # otherwise, we display the form again. We've got the form field + # values in $data and will put those back in the filds below. You + # should add some message asking people to fix their entry in + # whatever way you require. + } else { + # form not submitted, you can set default values like so: + #$data = array('name' => 'Yes'); + $data = array(); + } + + tem_set('form', $data); +}