blob: d96d39aae8e21894ac7ef750d956f3404088806b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<?php
function submitComment()
{
// Get the content sent from the comment form
$comment = htmlentities($_POST['userContent']);
$postURL = $_POST['postURL'];
// Set default values if blank
if (isset($_POST['userName']) && trim($_POST['userName']) !== "") {
$username = $_POST['userName'];
} else {
$username = null;
}
// Create a 'Comment' object
include_once('_classes/Comment.php');
$userComment = new Comment($comment, $postURL, $username);
// Append comment to JSON file
$userComment->saveComment('_data/comments.json');
// Send the user back
header('Location: ' . $postURL . '#comments');
}
|