-
Notifications
You must be signed in to change notification settings - Fork 0
/
get2.php
45 lines (43 loc) · 1.83 KB
/
get2.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
44
45
<?php
header('Access-Control-Allow-Origin: *'); // IMPORTANTE CORS “Access-Control-Allow-Origin” mancante
header ("Access-Control-Expose-Headers: Content-Length, X-JSON");
header ("Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS");
header ("Access-Control-Allow-Headers: Content-Type, Authorization, Accept, Accept-Language, X-Authorization");
header('Access-Control-Max-Age: 86400');
header('Content-Type: application/json; charset=UTF-8');
try {
if($_SERVER['REQUEST_METHOD'] === "POST") {
$POST = filter_var_array($_POST, FILTER_SANITIZE_STRING);
$id = $POST['id'];
$email = $POST['email'];
$usr = $POST['usr'];
$psw = $POST['psw'];
$age = $POST['age'];
echo '[
{
"id" : "'.$id.'",
"email" : "'.$email.'",
"usr" : "'.$usr.'",
"psw" : "'.$psw.'",
"age" : "'.$age.'",
"method" : "POST",
"avatar" : "default.png"
}
]';
} else {
throw new Exception("NOT POST", 500);
}
} catch(Exception $e) {
echo '[
{
"id" : "messaggio di errore: '.$e->getMessage().'",
"email" : "codie di errore: '.$e->getCode().'",
"usr" : "linea dove si è verificato l\'errore: '.$e->getLine().'",
"psw" : "file: '.$e->getFile().'",
"age" : "errore di sintassi",
"method" : "ERROR",
"avatar" : "default.png"
}
]';
}
?>