-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuploadComment.php
44 lines (27 loc) · 1.01 KB
/
uploadComment.php
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
43
44
<?php include 'filter.php'; ?>
<?php include 'functions.php'; ?>
<?php
if (loggedIn()){
// receive comment
$comment = $_REQUEST["comment"]; // store comment
$comment = addslashes($comment); // add slashes
$status_id = $_REQUEST["statusid"]; // get statusid
$servername = "mydb";
$username = "root";
$password = "mysqlPwd75";
$dbname = "project";
// Create connection
$link = mysqli_connect($servername, $username, $password, $dbname) or die('Could not connect: ' . mysqli_connect_error());
$sqlInsert = "Insert into comments (status_id, commented_user, comment) VALUES (\"" . $status_id . "\", \"" . $_SESSION["username"]. "\",\"" . $comment. "\");";
if ($link->query($sqlInsert) === TRUE){
echo "Your comment has been uploaded. Refreshing in a moment...";
echo "<script>setTimeout(\"location.href = 'home.php';\",1500);</script>";
} else {
echo $link->error;
}
$link->close();
return;
} else {
header("location:index.php");
}
?>