forked from JohanGriesel/Stratusolve-Exercise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_task.php
More file actions
25 lines (20 loc) · 737 Bytes
/
Copy pathupdate_task.php
File metadata and controls
25 lines (20 loc) · 737 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
<?php
/**
* This script is to be used to receive a POST with the object information and then either updates, creates or deletes the task object
*/
require_once('task.class.php');
// Assignment: Implement this script
if (isset($_POST) ) {
$action = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_STRING);
$taskId = filter_input(INPUT_POST, 'task_id', FILTER_SANITIZE_NUMBER_INT);
$taskClass = new Task($taskId);
if ($action == 'save') {
$taskClass->Save();
}
if ($action == 'delete') {
$taskClass->Delete();
}
}
echo json_encode(['message' => 'You either tried accessing this directly or submitted an invalid action. Please trying saving the form again', 'success'=>false]);
exit;
?>