require_once 'core/init.php'; // define variables and set to empty values $topic = $description = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $topic = test_input($_POST["topic"]); $description = test_input($_POST["description"]); } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $new_forum_topic = new ForumPost(); $new_forum_topic->createNew(array('category_title' => $topic, 'category_description' => $description)); $new_forum_topic->register(); $allposts = forumPost::getallForum(); foreach ($allposts as $key => $value) { $title = $value->get_Title(); $des = $value->get_Description(); echo "<a href='#' class='cat_links'> <b>{$title}</b> : <hr> <br><i>{$des}</i></a><br> "; } ?> </div> </div> <?php
if (isset($_POST['description'])) { $topic = test_input($_POST["topic"]); $description = test_input($_POST["description"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } //update forum_post table if (isset($_POST['submit'])) { $new_forum_topic = new ForumPost(); $new_forum_topic->createNew(array('post_title' => $topic, 'post_description' => $description, 'posted_user' => $name, 'posted_date' => $date)); $new_forum_topic->register(); header('Location: forum_p.php'); exit; } ob_flush(); //Get details from forum_post table echo "<div class='datagrid'><table>\n <thead><tr><th>Discussion</th><th>Posted by</th><th>Date</th></tr></thead>"; $allposts = ForumPost::getallForum(); foreach ($allposts as $key => $value) { $id = $value->get_id(); $title = $value->get_Title(); #$des=$value->get_Description(); $pst_usr = $value->get_Posteduser(); $pst_date = $value->get_Postdate(); //echo "<a href='forum_view_posts.php?cid=".$id."' class='cat_links'> <b>$title</b>: <br> Posted By <i>$pst_usr</i> </a> ";