-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroutes.php
More file actions
45 lines (44 loc) · 1.35 KB
/
Copy pathroutes.php
File metadata and controls
45 lines (44 loc) · 1.35 KB
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
38
39
40
41
42
43
44
45
<?php
require 'controllers/noteController.php';
$route = $_GET['route'] ?? 'notes.index';
switch ($route) {
case 'notes.index':
$notes = getNotes();
include 'views/header.php';
include 'views/notes_list.php';
include 'views/footer.php';
break;
case 'notes.create':
include 'views/header.php';
include 'views/form.php';
include 'views/footer.php';
break;
case 'notes.store':
storeNote();
header("Location: index.php?route=notes.index");
break;
case 'notes.edit':
$note = getNoteById($_GET['id']);
include 'views/header.php';
include 'views/edit_form.php';
include 'views/footer.php';
break;
case 'notes.update':
updateNote($_POST['id'], $_POST['title'], $_POST['content']);
header("Location: index.php?route=notes.index");
break;
case 'notes.delete':
deleteNoteById($_GET['id']);
header("Location: index.php?route=notes.index");
break;
case 'notes.search':
$search = $_GET['search'] ?? '';
$field = $_GET['field'] ?? '';
$notes = findNotesBySearch($search, $field);
include 'views/header.php';
include 'views/notes_list.php';
include 'views/footer.php';
break;
default:
echo "404 - Page not found";
}