annotate submit_comment.php @ 35:a30aee3f6158

simple form handler for submitting a comment. This script just forwards the comment via eMail.
author Dirk Olmes <dirk@xanthippe.ping.de>
date Mon, 01 Sep 2014 04:15:01 +0200
parents
children cf31bf5fce72
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
1 <?php
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
2 function get_slug()
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
3 {
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
4 $slug = htmlspecialchars($_POST['Slug']);
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
5 if (empty($slug))
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
6 {
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
7 die('POST request did not include value for required key "Slug"');
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
8 }
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
9 return $slug;
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
10 }
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12 if ($_SERVER['REQUEST_METHOD'] == 'POST')
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13 {
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
14 $recipient = 'blog@xanthippe.ping.de';
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
15 $slug = get_slug();
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
16
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
17 $author = htmlspecialchars($_POST['Author']);
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
18 $comment = htmlspecialchars($_POST['Comment']);
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
19 $date = date('Y-m-d H:i:s');
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
20
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
21 $message = 'Author: ' . $author . PHP_EOL
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
22 . 'Date: ' . $date . PHP_EOL . PHP_EOL
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
23 . $comment;
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
24
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
25 $subject = 'New blog post comment on article ' . $slug;
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
26 mail($recipient, $subject, $message);
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
27
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
28 ?>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
29
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
30 <html>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
31 <head>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
32 <title>Your comment was posted</title>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
33 </head>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
34 <body>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
35 <h1>Thank you</h1>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
36 <p>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
37 Your comment was posted and will appear on the blog as soon as a moderator has reviewed it.
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
38 </p>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
39 <a href="http://xanthippe.duckdns.org/blog/">Back to the blog</a>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
40 </body>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
41 </html>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
42
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
43 <?php
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
44 }
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
45 ?>