<?php date_default_timezone_set("Asia/Manila"); $date = date('Y-m-d H:i:s'); if (isset($_POST['btnpost'])) { include_once "post.php"; $param = array("postTitle" => $_POST["title"], "postDesc" => $_POST["desc"], "userID" => $_SESSION['id'], "topicID" => $_GET['topicid'], "datePosted" => $date, "postStatus" => 1, "postLevel" => $_SESSION['level']); $query = new post(); $query->create("tblpost", $param); } if (isset($_POST['btntopic'])) { include_once "topic.php"; $param = array("topicTitle" => $_POST["title"], "topicDesc" => $_POST["content"], "dateCreated" => $date, "forumCatID" => $_POST["cbocategory"], "topicStatus" => 1); $query = new topic(); $query->create("tbltopic", $param); } if (isset($_POST['btnreply'])) { include_once "post.php"; $param = array("replyContent" => $_POST["message"], "postID" => $_GET["postid"], "userID" => $_SESSION["id"], "datePosted" => $date, "replyLevel" => $_SESSION["level"], "replyStatus" => 1); $query = new post(); $query->add("tblreply", $param); }
<?php require "../../includes/conf.inc.php"; require "../../includes/functions.inc.php"; if (isset($_POST['postTitle'])) { $adminId = $_SESSION['adminId']; $postTitle = $_POST['postTitle']; $postTypId = $_POST['postTypId']; $subjectId = $_POST['subjectId']; $imp = $_POST['imp']; $postText = $_POST['postText']; $postTitle = ucfirst(sanitize_text($postTitle)); $postText = trim(mysql_real_escape_string(stripslashes($postText))); if ($postTitle == '' || $postText == '') { //when any entry is empty $response = array('success' => 0, 'error' => 1, 'errorMsg' => 'Either Post Title Or Post Body is empty!'); } else { $newPost = array('postTitle' => $postTitle, 'postText' => $postText, 'subjectId' => $subjectId, 'postTypId' => $postTypId, 'adminId' => $adminId, 'statusId' => 2, 'imp' => $imp); if (!post::create($newPost)) { $response = array('success' => 0, 'error' => 2, 'errorMsg' => 'Opps! Something Went Wrong!'); } else { $response = array('success' => 1, 'error' => 0); } } /*$_SESSION['response'] = $response; header("location: add.php");*/ echo json_encode($response); }