-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddreview.php
More file actions
45 lines (30 loc) · 947 Bytes
/
Copy pathaddreview.php
File metadata and controls
45 lines (30 loc) · 947 Bytes
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
45
<?php
/**
* Created by IntelliJ IDEA.
* User: mithishri
* Date: 9/29/2016
* Time: 3:09 AM
*/
session_start();
include('conn.php');
print_r($_POST);
$rating = $_POST['rating'];
$review = $_POST['review'];
$now = date('Y-m-d H:i:s');
$resid = $_SESSION['res_id'];
$uid = $_SESSION['id'];
$uname = $_SESSION['name'];
$query = "SELECT * FROM reviews where u_id = $uid AND res_id = '$resid' LIMIT 1";
if ($results = mysqli_query($link, $query)) {
if (mysqli_num_rows($results)) {
$query = "UPDATE reviews SET review = '$review', rating = '$rating', r_date = '$now' WHERE u_id = $uid AND res_id = '$resid'";
} else {
$query = "INSERT INTO reviews (rating, review, res_id, u_id , r_date, u_name)
VALUES ($rating, '$review', '$resid',$uid,'$now', '$uname' )";
}
if ($results = mysqli_query($link, $query)) {
echo 'done';
}
} else
echo mysqli_error($link);
echo $query;