-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd-comment.php
More file actions
30 lines (23 loc) · 955 Bytes
/
Copy pathadd-comment.php
File metadata and controls
30 lines (23 loc) · 955 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
26
27
28
29
30
<?php
session_start();
if (!isset($_SESSION['loggedin'])) {
header('Location: index.php');
exit;
}
$userId = $_SESSION['UserId'];
include 'connect-db.php';
$commenter_userId = $_POST['commenter_userId'] ?? '';
$commentee_userId = $_POST['commentee_userId'] ?? '';
$comment_content = $_POST['comment_content'] ?? '';
$commentee_username = $_POST['commentee_username'] ?? '';
$score = $_POST['score'] ?? '';
$insert_sql = "INSERT INTO Comment (commenter_userId, commentee_userId, score, comment_content) VALUES (?, ?, ?, ?)";
$insert_stmt = $db->prepare($insert_sql);
$insert_stmt->execute([$commenter_userId, $commentee_userId, $score, $comment_content]);
$CommentId = $db->lastInsertId();
$writes_sql = "INSERT INTO Writes_Comment (CommentID, userID) VALUES (?, ?)";
$writes_stmt = $db->prepare($writes_sql);
$writes_stmt->execute([$CommentId, $commenter_userId]);
header('Location: profile.php?username=' . $commentee_username);
exit;
?>