From 0ecae4e72d7d4ace51b731ff2c5d5eb63351e3e1 Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Wed, 24 Mar 2021 19:01:51 -0600 Subject: Add thread replies, sort threads by last reply --- create_thread.php | 31 +++---------------------------- includes/functions_insert.php | 35 +++++++++++++++++++++++++++++++++++ index.php | 13 ------------- model/Category.php | 2 +- thread.php | 30 +++++++++++++++++++++++++++++- 5 files changed, 68 insertions(+), 43 deletions(-) create mode 100644 includes/functions_insert.php diff --git a/create_thread.php b/create_thread.php index bc77cc7..dc0ce06 100644 --- a/create_thread.php +++ b/create_thread.php @@ -40,32 +40,7 @@ if (!isset($_SESSION['signed_in'])) { -

More from the forum

- - - - - - - - - - - -
Recent PostsRecent ThreadsPopular Threads
test
test
test
test
test
test
test
test
test
test
test
test
\ No newline at end of file diff --git a/model/Category.php b/model/Category.php index 4e57f46..5a2c11c 100644 --- a/model/Category.php +++ b/model/Category.php @@ -33,7 +33,7 @@ class Category { } function get_threads($dbc) { - $sql = "SELECT thread_id FROM threads WHERE thread_category = " . $this->id; + $sql = "SELECT thread_id FROM threads WHERE thread_category = " . $this->id . " ORDER BY thread_date_lastpost"; $result = mysqli_query($dbc, $sql); if (!$result) { diff --git a/thread.php b/thread.php index 3a65114..0d516da 100644 --- a/thread.php +++ b/thread.php @@ -30,5 +30,33 @@ if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) { $post->display_content(); } ?> +
+

Reply to this thread

+
+ +
+ +
- \ No newline at end of file + +signed in 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 -- cgit v1.2.3