From 2805ef7311eeb028cd48bffe04a705676c4682be Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Sun, 21 Mar 2021 10:54:47 -0600 Subject: big changes pt1 --- create_thread.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'create_thread.php') diff --git a/create_thread.php b/create_thread.php index 51bfe10..ae3168b 100644 --- a/create_thread.php +++ b/create_thread.php @@ -1,9 +1,12 @@ + + + + + Create a thread - cflip.net forum + + +

Create a new thread

Create a new thread

'; - if (!isset($_SESSION['signed_in'])) { die('You must be signed in to create a thread.'); } @@ -44,7 +47,8 @@ if (!isset($_SESSION['signed_in'])) { include_once 'includes/db_inc.php'; function create_thread($dbc, $thread_subject, $thread_cat, $thread_author) { - $sql = "INSERT INTO threads(thread_subject, thread_date, thread_cat, thread_author) VALUES(?, NOW(), ?, ?);"; + $sql = "INSERT INTO threads(thread_subject, thread_date_created, thread_date_lastpost, thread_category, thread_author) VALUES(?, CONVERT_TZ(NOW(),'SYSTEM','+00:00'), CONVERT_TZ(NOW(),'SYSTEM','+00:00'), ?, ?); + UPDATE categories SET cat_thread_count = cat_thread_count + 1 WHERE cat_id = " . $thread_cat . ';'; $stmt = mysqli_stmt_init($dbc); if (!mysqli_stmt_prepare($stmt, $sql)) { @@ -56,8 +60,9 @@ function create_thread($dbc, $thread_subject, $thread_cat, $thread_author) { mysqli_stmt_close($stmt); } -function create_post($dbc, $post_content, $post_thread, $post_author) { - $sql = "INSERT INTO posts(post_content, post_date, post_thread, post_author) VALUES(?, NOW(), ?, ?);"; +function create_post($dbc, $post_content, $post_thread, $post_category, $post_author) { + $sql = "INSERT INTO posts(post_content, post_date, post_thread, post_author) VALUES(?, CONVERT_TZ(NOW(),'SYSTEM','+00:00'), ?, ?); + UPDATE categories SET cat_post_count = cat_post_count + 1 WHERE cat_id = " . $post_category; $stmt = mysqli_stmt_init($dbc); if (!mysqli_stmt_prepare($stmt, $sql)) { @@ -90,7 +95,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { } else { create_thread($dbc, $thread_subject, $thread_cat, $user_id); $thread_id = mysqli_insert_id($dbc); - $post_result = create_post($dbc, $post_content, $thread_id, $user_id); + $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 { @@ -100,7 +105,5 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { } ?> - - - - + + \ No newline at end of file -- cgit v1.2.3