<?php
/**
* ProjectPress create forum topic
*
* @package ProjectPress
* @since 2.0
*/
// Starts the session.
session_start();
define('access',true);
include(dirname(dirname(__FILE__)) . '/config.inc.php');
include(PM_DIR . 'pm-includes/global.inc.php');
require(PM_DIR . 'pm-includes/functions.php');
include(PM_DIR . 'pm-includes/header.php');
// Checks if user is logged in; if not redirect to login page.
if($current_user->hasPermission('access_site') != true) { pm_redirect(PM_URI . '/index.php'); }
// Enable for error checking and troubleshooting.
# display_errors();
if($_POST) {
$topic = pmdb::connect()->escape($_POST['topic']);
$detail = pmdb::connect()->escape($_POST['detail']);
$datetime = pmdb::connect()->escape(date("d/m/y h:i:s")); //create date time
$username = $_SESSION['username'];
$sql = "INSERT INTO ". DB ."forum_question(topic, detail, q_user, datetime)VALUES('$topic', '$detail', '$username', '$datetime')";
$result = pmdb::connect()->query($sql);
}
/**
* Creates a new template for the create a topic page.
*/
$newtopic = new Template(PM_DIR . "pm-includes/tpl/create_topic.tpl");
$newtopic->set("pmurl", get_pm_option('siteurl'));
/**
* Outputs the page for create a topic.
*/
echo $newtopic->output();
include(PM_DIR . 'pm-includes/footer.php');