forked from asams/travelGuide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cityCommentSubmitted.php
33 lines (21 loc) · 1.05 KB
/
cityCommentSubmitted.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
<?php
header('Location: city.php?id=' . $_POST['city_id']);
include('header_side.php');
include('db_connect.php');
$subjectSubmitted = $_POST['subject'];
$commentSubmitted = $_POST['comment'];
$date = getdate();
$commentCity = $_POST['city_id'];
$timestamp = $date[year] . "-" . $date[mon] . "-" . $date[mday]
. " " . $date[hours] . ":" . $date[minutes] . ":" . $date[seconds];
$userID = $_COOKIE['user_id'];
$subject = mysqli_real_escape_string($db, strip_tags(trim($subjectSubmitted)));
$comment = mysqli_real_escape_string($db, strip_tags(trim($commentSubmitted)));
//if all the fields are completed, then insert the new comment into the cities' comments table
if (($userID != "") AND ($subject != "") AND ($comment != "")){
$query = "INSERT INTO city_comments (`city_id`, `user_id`, `comment_subject`, `comment_body`, `comment_date_submitted`)
VALUES ('$commentCity', '$userID', '$subject', '$comment', '$timestamp')";
$result = mysqli_query($db, $query) or die ("Error Querying Database");
mysqli_close($db);
}
?>