-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbook.php
45 lines (32 loc) · 1.05 KB
/
book.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
<?php
session_start();
include "connect.php";
include "functions.php";
$user_data = check_login($conn);
$id = $_SESSION['user_id'];
echo $id;
if(isset($_POST['submit_book'])){
$new = $_POST['submit_book'];
$query="INSERT INTO `bookings`(`event_id`,`user_id`) VALUES('$new','$id')";
$result=mysqli_query($conn,$query);
// echo $result;
// echo $query;
if($result){
header("Location:index.php");
}else{
echo("ERROR: ".$query."<br>".mysqli_error($conn));
}
}
if(isset($_POST['delete_book'])){
$bookingid = $_POST['delete_book'];
// deleting booked event
$sqldeleteEvent = "DELETE FROM `bookings` WHERE `booking_id` = $bookingid && `user_id` = $id";
// check if insert is successful
if(mysqli_query($conn, $sqldeleteEvent)){
header("Location: index.php");
}
else{
echo("ERROR: ".$sqldeleteEvent."<br>".mysqli_error($conn));
}
}
?>