-
Notifications
You must be signed in to change notification settings - Fork 0
/
order_cancel.php
58 lines (51 loc) · 1.1 KB
/
order_cancel.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
<?php
require 'core_login.php';
require 'database_connect.php';
if(loggedin())
{
if(isset($_POST['order']))
{
$order_id = $_POST['order'];
$query = "SELECT user_id, status FROM `orders` WHERE order_id=".$order_id;
$query_run = mysqli_query($connect,$query);
while($row = mysqli_fetch_assoc($query_run))
{
$user_id = $row['user_id'];
$status = $row['status'];
}
if($status != '0')
{
?>
<script type="text/javascript">
alert('The order cannot be cancelled as we have started preparing it!');
location.replace('<?php echo $http_referer ?>');
</script>
<?php
die();
}
if($user_id == $_SESSION['user_id'])
{
$query = "UPDATE orders SET status=5 WHERE order_id=".mysqli_real_escape_string($connect,$order_id);
$query_run = mysqli_query($connect,$query);
?>
<script type="text/javascript">
alert('Order Cancelled Successfully');
location.replace('<?php echo $http_referer ?>');
</script>
<?php
}
else
{
header('Location: view_orders.php');
}
}
else
{
header('Location: view_orders.php');
}
}
else
{
header('Location: login.php');
}
?>