-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi.php
42 lines (41 loc) · 1.02 KB
/
api.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
header("Content-Type: text/html; charset=utf-8");
require_once 'connectBD.php';
require_once 'request.php';
$error = json_encode('{
"status" : "Error",
"message": "Wrong request!"
}');
switch($_REQUEST['action']){
case 'add':
if(!empty($_POST))
$ans = add($mysqli, $_POST);
else
$ans = $error;
print $ans;
break;
case 'read':
if(!empty($_GET))
$ans = display($mysqli);
else
$ans = $error;
print $ans;
break;
case 'update':
if(!empty($_POST))
$ans = edit($mysqli, $_POST);
else
$ans = $error;
print $ans;
break;
case 'delete':
if(!empty($_POST))
$ans = del($mysqli, $_POST);
else
$ans = $error;
print $ans;
break;
default:
break;
}
?>