Save tasks in JSON pretty print, and fixed todo.html addtask()

This commit is contained in:
Lutchy Horace 2024-01-29 07:36:56 -05:00
parent a701c2974c
commit 34e0f341ef
4 changed files with 34 additions and 5 deletions

View file

@ -1,8 +1,9 @@
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$data = json_decode(file_get_contents("php://input"), true);
var_dump($data);
// Store tasks in a flat-file database (tasks.txt)
file_put_contents("tasks.txt", implode("\n", $data["tasks"]));
$ret = file_put_contents("tasks.json", json_encode($data["tasks"], JSON_PRETTY_PRINT));
var_dump($ret);
}
?>