-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdeleteEvent.php
More file actions
40 lines (35 loc) · 971 Bytes
/
deleteEvent.php
File metadata and controls
40 lines (35 loc) · 971 Bytes
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
<?php
require 'database.php';
ini_set("session.cookie_httponly", 1);
session_start();
$id_num = (int)$_POST['event_id'];
$token = (int)$_POST['token'];
if(!hash_equals($_SESSION['token'], $_POST['token'])){
die("Request forgery detected");
}
// Delete event where event_id matches that passed to it by JavaScript function call
$stmt = $mysqli->prepare("delete from events where event_id=?");
if(!$stmt){
echo json_encode(array(
"success" => false,
"message" => "Incorrect Username or Password"
));
exit;
}
$stmt->bind_param('s', $id_num);
$stmt->execute();
$stmt->close();
// Then we delete the actual event itself
$stmt = $mysqli->prepare("delete from events where event_id=?");
if(!$stmt){
printf("Query Prep Failed: %s\n", $mysqli->error);
exit;
}
$stmt->bind_param('s', $file_name);
$stmt->execute();
$stmt->close();
echo json_encode(array(
"success" => true,
));
exit;
?>