-
Notifications
You must be signed in to change notification settings - Fork 0
/
product_rateEx.php
52 lines (39 loc) · 1.61 KB
/
product_rateEx.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
45
46
47
48
49
50
51
52
<?php
include "db_conn.php";
if (isset($_POST['product']) && isset($_POST['user']) && isset($_POST['seller']) && isset($_POST['comment']) && isset($_POST['rate'])) {
$product = $_POST["product"];
$user = $_POST["user"];
$seller = $_POST["seller"];
$comment = $_POST["comment"];
$rate = $_POST["rate"];
$sql1 = "SELECT * FROM `market` WHERE `name` = '$product' AND `seller` = '$seller'";
$result1 = mysqli_query($conn, $sql1);
if (mysqli_num_rows($result1) > 0) {
$row1 = mysqli_fetch_array($result1);
$productid = $row1["productid"];
$sql2 = "SELECT * FROM `product_rating` WHERE `productid` = '$productid' AND `seller` = '$seller'";
$result2 = mysqli_query($conn, $sql2);
if ($result2 && mysqli_num_rows($result2) > 0) {
echo "Existing";
} else {
// Get the current time in the Philippines
date_default_timezone_set('Asia/Manila');
$currentDateTime = date('Y-m-d H:i:s');
$date = date('Y-m-d', strtotime($currentDateTime));
$time = date('H:i:s', strtotime($currentDateTime));
$sql3 = "INSERT INTO `product_rating`(`productid`,`user`, `seller`, `rate`, `comment`, `date`, `time`)
VALUES ('$productid','$user','$seller','$rate','$comment','$date','$time')";
$result3 = mysqli_query($conn, $sql3);
if ($result2){
echo "Success";
} else {
echo "Failed";
}
}
} else {
echo "Product-Name";
}
} else {
echo "Unknown";
}
?>