-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandlecomment.php
More file actions
42 lines (32 loc) · 1.38 KB
/
Copy pathhandlecomment.php
File metadata and controls
42 lines (32 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
require 'partials/_dbconnect.php';
if(isset($_REQUEST['submit']))
{
$add_comment = $_REQUEST['add-comment'];
$thread_id = $_REQUEST['thread-id'];
$comment_by = $_REQUEST['comment-by'];
$getCommentUserIdSql = "SELECT user_id FROM `users` WHERE username = '$comment_by'";
$getCommentUserIdSqlResult = mysqli_query($conn, $getCommentUserIdSql);
$get_comment_by_id = mysqli_fetch_assoc($getCommentUserIdSqlResult);
$comment_by_id = $get_comment_by_id['user_id'];
$add_comment = str_replace("<", "<", $add_comment);
$add_comment = str_replace(">", ">", $add_comment);
$add_comment = str_replace("'", "'", $add_comment);
$sql = "INSERT INTO `comments` (`comment_content`, `thread_id`, `comment_by`, `comment_time`) VALUES ('$add_comment', '$thread_id', '$comment_by_id', current_timestamp())";
$result = mysqli_query($conn, $sql);
if($result)
{
if(isset($_REQUEST['thread_page_comment'])){
$comment_thread_id = $_REQUEST['thread_page_comment'];
echo '<script>
window.location = "thread.php?tid='.$comment_thread_id.'";
</script>';
}
else{
echo '<script>
window.location = "index.php";
</script>';
}
}
}
?>