-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit_comment.php
More file actions
25 lines (20 loc) · 888 Bytes
/
Copy pathsubmit_comment.php
File metadata and controls
25 lines (20 loc) · 888 Bytes
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
<?php
session_start();
require "includes/db.php";
if($_SERVER['REQUEST_METHOD'] === 'POST'){
$blog_id = intval($_POST['blog_id']);
$name = $conn->real_escape_string($_POST['name']);
$email = $conn->real_escape_string($_POST['email']);
$website = $conn->real_escape_string($_POST['website']);
$comment = $conn->real_escape_string($_POST['comment']);
$sql = "INSERT INTO blog_comments (blog_id, commenter_name, commenter_email, commenter_website, comment_text, status)
VALUES ($blog_id, '$name', '$email', '$website', '$comment', 'pending')";
if($conn->query($sql)){
$_SESSION['comment_msg'] = "Your comment has been submitted and is awaiting approval.";
} else {
$_SESSION['comment_msg'] = "Failed to submit comment. Please try again.";
}
header("Location: blog_detail.php?id=$blog_id#comments");
exit;
}
?>