-
-
Notifications
You must be signed in to change notification settings - Fork 391
/
review.php
96 lines (35 loc) · 1.13 KB
/
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
36
37
38
39
40
41
42
<?php
session_start();
include "db.php";
if (isset($_POST["review"])) {
$name = $_POST["name"];
$email = $_POST["email"];
$review = $_POST['review'];
$rating = $_POST['rating'];
$product_id =$_POST['product_id'];
$datetime = date('Y-m-d H:i:s');
$sql = "SELECT review_id FROM reviews WHERE email = '$email' AND product_id = '$product_id' ";
$check_query = mysqli_query($con,$sql);
$count_email = mysqli_num_rows($check_query);
if($count_email > 0){
echo "
<div class='alert alert-danger'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<b>Multiple reviews are not Allowed</b>
</div>
";
exit();
}else{
$sql = "INSERT INTO `reviews` (`review_id`, `product_id`, `name`, `email`, `review`, `datetime`, `rating`)
VALUES (NULL, '$product_id','$name', '$email',
'$review','$datetime', '$rating')";
if(mysqli_query($con,$sql)){
echo "Thanks for Better reach ";
echo "<script> location.href='product.php?q=$product_id'; </script>";
exit;
}else {
echo "something went wrong";
}
}
}
?>