-
Notifications
You must be signed in to change notification settings - Fork 2
/
deleteFromPlanner.php
41 lines (32 loc) · 1.61 KB
/
deleteFromPlanner.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
<?php
require 'connect.php';
header('Access-Control-Allow-Origin: https://engineersabroad.uvacreate.virginia.edu'); //comment out when using localhost
//header('Access-Control-Allow-Origin: http://localhost:4200'); //comment out when using hosted server
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT');
// get the size of incoming data
//$content_length = (int) $_SERVER['CONTENT_LENGTH'];
// retrieve data from the request
$postdata = file_get_contents("php://input");
// Process data
// (this example simply extracts the data and restructures them back)
if(isset($postdata) && !empty($postdata)){
// Extract json format to PHP array
$request = json_decode($postdata, TRUE);
$email = mysqli_real_escape_string($con, trim($request['email']));
$program = mysqli_real_escape_string($con, trim($request['program']));
$transferredCourses = mysqli_real_escape_string($con, trim($request['transferredCourses']));
$country = mysqli_real_escape_string($con, trim($request['country']));
$sql = "DELETE FROM `planner` WHERE (email='{$email}' AND program='{$program}' AND transferredCourses='{$transferredCourses}' AND country = '{$country}')";
if(mysqli_query($con, $sql)){
http_response_code(201);
echo json_encode(true);
}
else{
http_response_code(422);
echo json_encode("Error Deleting Planner Object");
}
}
?>