forked from foysal-mamun/json-crud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathController.php
More file actions
37 lines (30 loc) · 706 Bytes
/
Controller.php
File metadata and controls
37 lines (30 loc) · 706 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
<?php
function __autoload($className){
include_once("models/$className.php");
}
$users=new User("your_host","your_user","your_password","your_database");
if(!isset($_POST['action'])) {
print json_encode(0);
return;
}
switch($_POST['action']) {
case 'get_users':
print $users->getUsers();
break;
case 'add_user':
$user = new stdClass;
$user = json_decode($_POST['user']);
print $users->add($user);
break;
case 'delete_user':
$user = new stdClass;
$user = json_decode($_POST['user']);
print $users->delete($user);
break;
case 'update_field_data':
$user = new stdClass;
$user = json_decode($_POST['user']);
print $users->updateValue($user);
break;
}
exit();