-
Notifications
You must be signed in to change notification settings - Fork 2
/
getUserPlannerObjects.php
37 lines (28 loc) · 1.17 KB
/
getUserPlannerObjects.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
<?php
session_start();
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-Headers: X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT');
$getdata = $_GET['str'];
if(isset($getdata) && !empty($getdata)){
$request = json_decode($getdata);
$userEmail = mysqli_real_escape_string($con, trim($request->email));
//handle all possible cases of entries and the proper SQL code
$sql = "SELECT * FROM planner WHERE email='$userEmail'";
if($result = mysqli_query($con, $sql)){
$rows = [];
while($row = mysqli_fetch_assoc($result)){
// echo json_encode($row);
$rows[] = $row; //add each row found into array
}
echo json_encode($rows);;
}
else{
echo mysqli_error($con);
echo json_encode(false);
http_response_code(404);
}
}
?>