diff options
author | cflip <36554078+cflip@users.noreply.github.com> | 2021-03-24 19:01:51 -0600 |
---|---|---|
committer | cflip <36554078+cflip@users.noreply.github.com> | 2021-03-24 19:01:51 -0600 |
commit | 0ecae4e72d7d4ace51b731ff2c5d5eb63351e3e1 (patch) | |
tree | 40ddad473bfc2e3e5c215da9ee0853044695737c /thread.php | |
parent | c9732788143886b611cb2fecfb53daf3d8add48f (diff) |
Add thread replies, sort threads by last reply
Diffstat (limited to 'thread.php')
-rw-r--r-- | thread.php | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -30,5 +30,33 @@ if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) { $post->display_content(); } ?> + <hr> + <h2>Reply to this thread</h2> + <form method="post"> + <textarea name="post_content" rows="10" cols="50"></textarea> + <br> + <input type="submit" name="submit"> + </form> </body> -</html>
\ No newline at end of file +</html> +<?php +include_once 'includes/db_inc.php'; +include_once 'includes/functions_insert.php'; + +if ($_SERVER['REQUEST_METHOD'] == 'POST') { + if (!isset($_SESSION['signed_in'])) { + echo 'You must be <a href="signin.php">signed in</a> to reply to this thread.'; + return; + } + + $post_content = filter_input(INPUT_POST, 'post_content', FILTER_SANITIZE_STRING); + $user_id = filter_var($_SESSION['user_id'], FILTER_SANITIZE_NUMBER_INT); + + if (empty($post_content) or !$post_content) { + echo 'Thread subject cannot be empty'; + } else { + insert_post($dbc, $post_content, $current->id, $user_id, $current->category->id); + } +} + +?>
\ No newline at end of file |