From a58cff1821ba0406ce7535b432963e6e2a002a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=B5=E9=96=8E=E5=82=91?= Date: Sun, 5 Jun 2016 17:33:04 +0800 Subject: [PATCH] Added comment deletion functions in comment.php --- comment.php | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++-- home.php | 38 ++++++++++----------- style.css | 10 ++++-- 3 files changed, 120 insertions(+), 23 deletions(-) diff --git a/comment.php b/comment.php index 25aeace..d6499ba 100644 --- a/comment.php +++ b/comment.php @@ -1,10 +1,57 @@ query($sql_select); + $target_obj = $target->fetch(PDO::FETCH_OBJ); + if($_SESSION['user']==$target_obj->uid) + { + $sql_del = "DELETE FROM messages WHERE messages.msg_id = ?"; + $stmt = $conn->prepare($sql_del); + $stmt->bindValue(1,$_POST["del_msg_id"]); + $stmt->execute(); + ?> + + query($sql_select); + $target_obj = $target->fetch(PDO::FETCH_OBJ); + if($_SESSION['user']==$target_obj->uid) + { + $sql_del = "DELETE FROM comments WHERE cmt_id = ?"; + $stmt = $conn->prepare($sql_del); + $stmt->bindValue(1,$_POST["del_msg_id"]); + $stmt->execute(); + ?> + + "; if(isset($_POST['view_reply_parent'])) { -$_SESSION['view_reply_parent'] = $_POST['view_reply_parent']; + $_SESSION['view_reply_parent'] = $_POST['view_reply_parent']; } $parent_id = $_SESSION['view_reply_parent']; if(isset($_POST['submit_comment'])) @@ -52,19 +99,41 @@ Message By Time + Delete fetch(PDO::FETCH_OBJ)) { echo "".$row -> msg.""; echo "".$row -> username.""; echo "".$row -> msg_time.""; + if($_SESSION['user']==$row->uid) + { + ?> + +
+