-
Notifications
You must be signed in to change notification settings - Fork 0
/
submit_review.php
35 lines (26 loc) · 901 Bytes
/
submit_review.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
<?php
require('database/connection.php');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$tour_id = $_POST['tour_id'];
$username = $_POST['username'];
$comment = $_POST['comment'];
$rating = (int) $_POST['rating'];
$stmt = $con->prepare("INSERT INTO reviews (tour_id, username, comment, rating, created_at) VALUES (?, ?, ?, ?, NOW())");
if ($stmt === false) {
die('Prepare failed: ' . htmlspecialchars($con->error));
}
$bind = $stmt->bind_param("isss", $tour_id, $username, $comment, $rating);
if ($bind === false) {
die('Bind failed: ' . htmlspecialchars($stmt->error));
}
if ($stmt->execute()) {
header("Location: place.php?tour_id=" . $tour_id . "&success=1");
exit;
} else {
header("Location: place.php?tour_id=" . $tour_id . "&error=1");
exit;
}
$stmt->close();
}
$con->close();
?>