diff --git a/www/notes/controllers/edit.php b/www/notes/controllers/edit.php index e69de29..c1efe56 100644 --- a/www/notes/controllers/edit.php +++ b/www/notes/controllers/edit.php @@ -0,0 +1,30 @@ + +query('SELECT * FROM notes WHERE id = :id', ...[ + 'id' => $_GET['id'], +])->fetch(); + + +// Note from another user +Core\authorize($note['user_id'] === $currentUserId); + + +// Fetch note +$title = "Note: {$_GET['id']}"; +require "views/edit.view.php"; \ No newline at end of file diff --git a/www/notes/routes.php b/www/notes/routes.php index b4ff705..dac30b5 100644 --- a/www/notes/routes.php +++ b/www/notes/routes.php @@ -5,5 +5,6 @@ $router->get('/', 'controllers/index.php'); $router->get('/note', 'controllers/note.php'); $router->delete('/note', 'controllers/destroy.php'); $router->post('/note', 'controllers/store.php'); +$router->get('/edit', 'controllers/edit.php'); $router->get('/create', 'controllers/create.php'); \ No newline at end of file diff --git a/www/notes/views/edit.view.php b/www/notes/views/edit.view.php new file mode 100644 index 0000000..0432691 --- /dev/null +++ b/www/notes/views/edit.view.php @@ -0,0 +1,23 @@ + + + + +