$ID = $db->real_escape_string(strip_tags(stripslashes($_GET['ID'])));
$GetThreadFromID = mysqli_fetch_object(mysqli_query($db, "SELECT * FROM ForumThreads WHERE ID=$ID"));
$GetThreadStarter = mysqli_fetch_object(mysqli_query($db, "SELECT * FROM Users WHERE ID='$GetThreadFromID->PosterID'"));
$GetTopicFromThread = mysqli_fetch_object(mysqli_query($db, "SELECT * FROM ForumTopics WHERE ID='$GetThreadFromID->ForumID'"));
$ThreadExist = mysqli_num_rows(mysqli_query($db, "SELECT * FROM ForumThreads WHERE ID='$ID'"));
$GetAllWatching = mysqli_query($db, "SELECT * FROM ForumWatchedThreads WHERE ThreadID='$ID' AND UserID='$client->ID'");
if ($ThreadExist == "0") {
echo "
<div class='container'>
<div class='panel panel-danger'>
<div class='panel-heading'>Error</div>
<div class='panel-body'>
The thread you requested does not exist.
</div>
</div>
</div>
";
include $_SERVER["DOCUMENT_ROOT"]."/_INCLUDES/Footer.php";
exit();
}
I have a website with a hand-coded forum. You can access forum threads fine. Say the thread ID is 12, but I put an apostrophe at the end of it in ?ID= then the forum title and forum body will be blank along with other information. How can I make it so it will display the thread with the ID, so if I put this in the URL bar: ?ID=13// or ?ID=13'', it will still display ?ID=13 without any interference, or even display an error saying that the forum thread does not exist?