//*   or any other code form this script cannot be
//*   used for other scripts or applications.
//*   You are not allowed to resell this script.
//* - You are free to make modification/changes,
//*   however it must be for your own use.
//*********************************************************************//
//start session
session_start();
include_once "general/general_class.php";
include_once "connection_to_db.php";
include_once "show_data_class.php";
$Data_display = new Data_display($conn);
include_once "create_thread/create_thread_class.php";
//$Create_thread = new create($conn);
//if get variable contains cat_id value..
if (isset($_GET["cat_id"])) {
    //show the threads that belong to that form
    $Data_display->show_threads();
    //if user is logged in then.. let him create a thread.
    if ($Data_display->is_user_logged_in("logged_in")) {
        echo "<form method=\"POST\" action=\"{$_SERVER['PHP_SELF']}?cat_id={$_GET['cat_id']}\">\n\t\t\t<p class='form_title'> Thread title: </p> <input name=\"thread_title\" type=\"text\"> </br>\n\t\t\t<p class='form_title'>Thread body: </p>  <textarea name=\"thread_body\" type=\"text\"></textarea></br>\n\t\t\t\t\t\t  <input name=\"submit_thread\" type=\"submit\" value=\"Submit thread\">\n\t\t\t</form>";
        //class to create thread.
        if (isset($_POST["submit_thread"])) {
            $Create = new create($conn);
        }
    } else {
        echo "You need to login to create a new thread";
    }
} else {
    echo header("location: index.php");
}