From ebf94d63edecf5263fe59c2ce3f08c7b0528e570 Mon Sep 17 00:00:00 2001
From: cflip <36554078+cflip@users.noreply.github.com>
Date: Sun, 21 Mar 2021 20:16:35 -0600
Subject: Fix thread creation form
---
TODO | 4 +--
create_thread.php | 78 +++++++++++++++++++++----------------------------------
2 files changed, 32 insertions(+), 50 deletions(-)
diff --git a/TODO b/TODO
index 65994ae..879a858 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,7 @@
IMPROVE EXISTING CODE
-[ ] Object-oriented code
+[v] Object-oriented code
[ ] Clean up table printing code
-[ ] Fix thread create page
+[v] Fix thread create page
[ ] Clean up links
[ ] Create 404 pages
diff --git a/create_thread.php b/create_thread.php
index ae3168b..bc77cc7 100644
--- a/create_thread.php
+++ b/create_thread.php
@@ -5,50 +5,44 @@
Create a thread - cflip.net forum
+
Create a new thread
signed in to create a thread.');
}
?>
-
-
Thread subject cannot be empty.';
+ echo 'Thread subject cannot be empty';
} else {
- create_thread($dbc, $thread_subject, $thread_cat, $user_id);
+ insert_thread($dbc, $thread_subject, $thread_cat, $user_id);
$thread_id = mysqli_insert_id($dbc);
- $post_result = create_post($dbc, $post_content, $thread_id, $thread_cat, $user_id);
- if (!$post_result) {
- echo 'An error occurred creating your post: ' . mysqli_error($dbc);
- } else {
- header("Location: thread.php?id=" . $thread_id);
- }
+ insert_post($dbc, $post_content, $thread_id, $user_id);
+
+ $sql = "UPDATE categories SET `cat_thread_count` = `cat_thread_count` + '1', `cat_post_count` = `cat_post_count` + '1' WHERE cat_id = " . $thread_cat . ";";
+ mysqli_query($dbc, $sql);
+
+ header("Location: /forum/thread/" . $thread_id);
}
}
-
?>