public function commentAction() { if ($_POST) { $content = $_POST['content']; $uid = $_POST['UID']; $aid = $_POST['AID']; $rid = $_POST['RID']; $abstract = substr($content, 0, 100); $time = date('Y-m-d H:i:s'); $comment = new comment(); $comment_arr = array('UID' => $uid, 'RID' => $rid, 'AID' => $aid, 'Time' => $time, 'Ccontent' => $content, 'Cabstract' => $abstract); $cid = $comment->insertComment($comment_arr); //$this->view->cid = $cid; echo $cid; //$this->render('commented'); } }
<?php require "../includes/conf.inc.php"; require "../includes/functions.inc.php"; if (isset($_POST['commentText']) && !empty($_POST['commentText'])) { $comment['commentText'] = sanitize_text($_POST['commentText']); $comment['userId'] = intval($_POST['userId']); $comment['postId'] = intval($_POST['postId']); $comment = comment::insertComment($comment); if ($comment == false) { echo false; } else { $cmmtDate = ago($comment['commentDate']); echo '<li class="comment"> <div class="commenterProfilePic"> <img src="' . $website . $comment['profilePicAddr'] . '"/> </div> <div class="commentDetail"> <a href="' . $website . 'account/profile/' . $comment['username'] . '" class="commenter">' . $comment['firstName'] . ' ' . $comment['lastName'] . '</a><br /> <p>' . $comment['commentText'] . '</p> <span>' . $cmmtDate . '</span> </div> <div class="cleaner"></div> </li>'; } }
<?php session_start(); if (isset($_SESSION['user'])) { $temp = $_SESSION['user']; } else { header("Location: ../views/signinPage.php?message=" . urlencode("Login again!")); } ?> <?php if ($_REQUEST['thecomment'] != "") { require_once "../models/comment.php"; $rs = comment::insertComment($_REQUEST['imgId'], $temp['username'], $_REQUEST['thecomment']); if ($rs == false) { echo "Comment not Added!", PHP_EOL; } } ?>