-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsubmit_comment.php
More file actions
31 lines (26 loc) · 1.01 KB
/
submit_comment.php
File metadata and controls
31 lines (26 loc) · 1.01 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
<?php
session_start();
error_reporting(E_ERROR | E_PARSE);
// If the session vars aren't set, try to set them with a cookie
if (!isset($_SESSION['user_id'])) {
if (isset($_COOKIE['user_id']) && isset($_COOKIE['username'])) {
$_SESSION['user_id'] = $_COOKIE['user_id'];
$_SESSION['username'] = $_COOKIE['username'];
}
}
?>
<?php
if(!empty($_POST['Comment'])){
$uploadedComment = $_POST['Comment'];
// echo $uploadedUrl;
}
$mysqli = new mysqli("localhost", "root", "", "linust_f");
//insert form data in the database
$insert = "INSERT INTO comments (user_id,course_name,comment,c_date) VALUES ('".$_SESSION['user_id']."', 'dbs','".$uploadedComment."', curdate())";
$answer = mysqli_query($mysqli, $insert);
mysqli_query($mysqli, "UPDATE users SET no_of_comments=no_of_comments+1 WHERE user_id='".$_SESSION['user_id']."'");
if($answer)
header("Location:CoursePage.php");
else
echo "Error:comment could not be submitted";
?>