diff options
author | cflip <36554078+cflip@users.noreply.github.com> | 2021-04-24 19:40:50 -0600 |
---|---|---|
committer | cflip <36554078+cflip@users.noreply.github.com> | 2021-04-24 19:40:50 -0600 |
commit | 2098bf444afadcf0363d89b4cc1dca5d2213d754 (patch) | |
tree | da93b29e22170d7be7c9ed215fde5238e9d76178 /includes/reply_inc.php | |
parent | aae25cd709d486f7ee9513753d40eb5cc239c42d (diff) |
Remove all uses of db_inc.php
This method of importing the database login every time wasn't very good.
Now everything uses the new Database singleton class.
Diffstat (limited to 'includes/reply_inc.php')
-rw-r--r-- | includes/reply_inc.php | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/includes/reply_inc.php b/includes/reply_inc.php index cf7a839..588b59f 100644 --- a/includes/reply_inc.php +++ b/includes/reply_inc.php @@ -1,10 +1,8 @@ <?php +include_once 'functions_post.php'; session_start(); -include_once 'db_inc.php'; -include_once 'functions_inc.php'; - if ($_SERVER['REQUEST_METHOD'] != 'POST') { die('This file cannot be called directly.'); } @@ -13,19 +11,12 @@ if (!isset($_SESSION['signed_in'])) { die('You must be signed in to reply to a thread.'); } -$reply_content = filter_var($_POST['reply_content'], FILTER_SANITIZE_STRING); -$reply_to = $_GET['reply_to']; -$post_author = $_SESSION['user_id']; - -$sql = "INSERT INTO posts(post_content, post_date, post_thread, post_author) VALUES(?, NOW(), ?, ?)"; -$stmt = mysqli_stmt_init($dbc); +$reply_content = filter_input(INPUT_POST, 'reply_content', FILTER_SANITIZE_STRING); +$thread_id = filter_input(INPUT_POST, 'reply_to', FILTER_SANITIZE_NUMBER_INT); -if (!mysqli_stmt_prepare($stmt, $sql)) { - die('Failed to process statement: ' . mysqli_error($dbc)); -} +$thread = new Thread(); +$thread->get_from_database($thread_id); -mysqli_stmt_bind_param($stmt, "sii", $reply_content, $reply_to, $post_author); -mysqli_stmt_execute($stmt); -mysqli_stmt_close($stmt); +create_post($reply_content, $thread_id, $thread->category); header("Location: ../thread.php?id=" . $_GET['reply_to']);
\ No newline at end of file |