-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcancel.php
43 lines (39 loc) · 1.05 KB
/
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
<?php
include("dbconnect.php");
$ren_id=$_GET['ren_id'];
$dat=$_GET['dat'];
$sql="SELECT pdate FROM rented WHERE ren_id='$ren_id' ";
$res = mysqli_query($conn,$sql);
$data = mysqli_fetch_assoc($res);
//echo $start= $data['pdate'];
$start= $data['pdate'];
// Converting to timestamp
$dat_ts = strtotime($dat);
$start_ts = strtotime($start);
if($dat_ts>= $start_ts)
{
echo "<script>
alert('can only cancel before pickup date!');
window.location.href='view_your_renting.php'</script>";
//echo"can only cancel before pickup date";
}
else
{
$sql1="DELETE FROM rented WHERE ren_id='$ren_id'";
$result= mysqli_query($conn,$sql1);
if($result)
{
echo "<script>
alert('booking is cancelled !');
window.location.href='view_your_renting.php'</script>" ;
//echo "data deleted";
}
else
{
echo "<script>
alert('error cannot delete !');
window.location.href='view_your_renting.php'</script>" ;
//echo "error cannot delete";
}
}
?>