-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsubmitrating.php
65 lines (58 loc) · 2.01 KB
/
submitrating.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
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
include_once ('./config.php');
$item_total=0;
$con=mysqli_connect($servername,$username,$password,$dbname);
if (mysqli_connect_errno())
{
echo 'Failed to connect to MySQL: ' . mysqli_connect_error();
}
if(isset($_COOKIE['UID']))
{
$itemid = $_GET['itemid'];
$orderid = $_GET['orderid'];
$rating = $_POST["itemrate"];
$userid= $_COOKIE['UID'];
$query_check = "select * from tbl_itemratings where itemID = $itemid and userID = $userid";
if ($con->query($query_check) == TRUE) { //if the user already rated on an item
echo'<script>
function myFunction() {
var r = confirm("You already rated this item!");
if (r == true) {
window.location.href = "orderdetails.php?orderid='.$orderid.'";
} else {
window.location.href = "orderdetails.php?orderid='.$orderid.'";
}
}
</script>
<script type="text/javascript">
myFunction();
</script>'
;
//header("location:/orderdetails.php?orderid=$orderid");
} else
{
$query="insert into tbl_itemratings (itemID,rating,userID,orderID)
values($itemid,$rating,$userid,$orderid)";
if ($con->query($query) == TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $query . "<br>" . $con->error;
}
}
}else{
echo'<script>
function myFunction() {
var r = confirm("Please Log In or Register to access this page!");
if (r == true) {
window.location.href = "login.php";
} else {
window.location.href = "index.php";
}
}
</script>
<script type="text/javascript">
myFunction();
</script>'
;
}
?>