diff options
author | cflip <36554078+cflip@users.noreply.github.com> | 2021-03-21 10:54:47 -0600 |
---|---|---|
committer | cflip <36554078+cflip@users.noreply.github.com> | 2021-03-21 10:54:47 -0600 |
commit | 2805ef7311eeb028cd48bffe04a705676c4682be (patch) | |
tree | 59c00c77d5bd59ea89967f18d5bcd6d1b5ad6e01 /create_thread.php | |
parent | f83530a122119d7f69812493f9c2f4987ccb2065 (diff) |
big changes pt1
Diffstat (limited to 'create_thread.php')
-rw-r--r-- | create_thread.php | 29 |
1 files changed, 16 insertions, 13 deletions
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 @@ +<?php session_start()?> +<!DOCTYPE html> +<html> +<head> + <title>Create a thread - cflip.net forum</title> +</head> +<body> +<h2>Create a new thread</h2> <?php - -include_once 'header.php'; - -echo '<section><h2>Create a new thread</h2>'; - if (!isset($_SESSION['signed_in'])) { die('You must be <a href="signin.php">signed in</a> 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') { } ?> - -</section> - -<?php include_once 'footer.php';?> +</body> +</html>
\ No newline at end of file |