diff --git a/comment.php b/comment.php index 7b66c0a..0d118a3 100644 --- a/comment.php +++ b/comment.php @@ -1,4 +1,5 @@ "; if(isset($_POST['view_reply_parent'])) @@ -8,27 +9,36 @@ $parent_id = $_SESSION['view_reply_parent']; if(isset($_POST['submit_comment'])) { - try - { - $uid = $_SESSION['user']; - $msg = $_POST['comment']; - $time = date('Y/m/d H:i:s'); - $insert = "INSERT INTO comments(cmt,uid,cmt_time,parent_id) VALUES(?,?,?,?)"; - $stmt = $conn->prepare($insert); - $stmt->bindValue(1,$msg); - $stmt->bindValue(2,$uid); - $stmt->bindValue(3,$time); - $stmt->bindValue(4,$parent_id); - $stmt->execute(); - ?> - + if($_POST['comment']!='') + { + try + { + $uid = $_SESSION['user']; + $msg = $_POST['comment']; + $time = date('Y/m/d H:i:s'); + $insert = "INSERT INTO comments(cmt,uid,cmt_time,parent_id) VALUES(?,?,?,?)"; + $stmt = $conn->prepare($insert); + $stmt->bindValue(1,$msg); + $stmt->bindValue(2,$uid); + $stmt->bindValue(3,$time); + $stmt->bindValue(4,$parent_id); + $stmt->execute(); + ?> + + ";//refresh the page + } + catch(Exception $e) + { + die(var_dump($e)); + } + } + else + { + ?> + ";//refresh the page - } - catch(Exception $e) - { - die(var_dump($e)); - } + } } //display the parent message diff --git a/header.php b/header.php index ec7293f..378d3cc 100644 --- a/header.php +++ b/header.php @@ -1,4 +1,5 @@
+