changed the post.php file to better fit with the new board_id identification
This commit is contained in:
parent
b1a8d2b6ce
commit
9de116b2f9
8
post.php
8
post.php
|
@ -7,13 +7,13 @@ function validate_iamge() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// function to handle the creation of a new thread
|
// function to handle the creation of a new thread
|
||||||
function new_thread(string $board_code, string $title, string $username) {
|
function new_thread(string $board_id, string $title, string $username) {
|
||||||
|
|
||||||
$conn = get_database_conn();
|
$conn = get_database_conn();
|
||||||
$insert_thread_sql = "INSERT INTO thread (title, user_id, board, posted)
|
$insert_thread_sql = "INSERT INTO thread (title, user_id, board, posted)
|
||||||
VALUES (?, (SELECT id FROM user WHERE username = ?), ?, NOW())";
|
VALUES (?, (SELECT id FROM user WHERE username = ?), ?, NOW())";
|
||||||
$stmt = mysqli_prepare($conn, $insert_thread_sql);
|
$stmt = mysqli_prepare($conn, $insert_thread_sql);
|
||||||
mysqli_stmt_bind_param($stmt, "sss", $title, $username, $board_code);
|
mysqli_stmt_bind_param($stmt, "sss", $title, $username, $board_id);
|
||||||
mysqli_stmt_execute($stmt);
|
mysqli_stmt_execute($stmt);
|
||||||
|
|
||||||
if (mysqli_stmt_affected_rows($stmt) != 1) {
|
if (mysqli_stmt_affected_rows($stmt) != 1) {
|
||||||
|
@ -37,7 +37,7 @@ if ($_POST['type'] == 'new_thread') {
|
||||||
// get the variables from the post request
|
// get the variables from the post request
|
||||||
$title = $_POST['title'] or die('invalid request!');
|
$title = $_POST['title'] or die('invalid request!');
|
||||||
$upload = $_POST['upload'] or die('invalid request!');
|
$upload = $_POST['upload'] or die('invalid request!');
|
||||||
$board_code = $_POST['board_code'] or die('invalid request!');
|
$board_id = $_POST['board_id'] or die('invalid request!');
|
||||||
$message = $_POST['message'] ?? '';
|
$message = $_POST['message'] ?? '';
|
||||||
|
|
||||||
// get the posters username
|
// get the posters username
|
||||||
|
@ -50,7 +50,7 @@ if ($_POST['type'] == 'new_thread') {
|
||||||
|
|
||||||
//todo: validate the image and move it into the filesystem
|
//todo: validate the image and move it into the filesystem
|
||||||
|
|
||||||
$thread_id = new_thread($board_code, $title, $username);
|
$thread_id = new_thread($board_id, $title, $username);
|
||||||
|
|
||||||
} elseif ($_POST['type'] == 'thread_reply') {
|
} elseif ($_POST['type'] == 'thread_reply') {
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue