-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax.php
More file actions
33 lines (30 loc) · 741 Bytes
/
Copy pathajax.php
File metadata and controls
33 lines (30 loc) · 741 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
<?php
/**
* Handle all AJAX requests for creating, deleting,
* editing, and completing tasks
*/
require_once 'config.php';
if (!array_key_exists('action', $_POST)) {
error_log("Direct access to ajax.php");
header("Location: ./");
}
$action = $_POST['action'];
unset($_POST['action']);
$Task = new Models\Task($DBH);
switch ($action) {
case 'create':
$_POST['user'] = $_SESSION['userid'];
$result = $Task->create($_POST);
break;
case 'delete':
$result = $Task->delete($_POST['id']);
break;
case 'edit':
$result = $Task->update($_POST);
break;
case 'complete':
$result = $Task->complete($_POST['id']);
break;
}
echo json_encode($result);
?>