-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnote.php
More file actions
62 lines (54 loc) · 1.7 KB
/
note.php
File metadata and controls
62 lines (54 loc) · 1.7 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
require_once 'includes/config.php';
require_once 'includes/functions.php';
try {
$pdo = new PDO(
"mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=utf8mb4",
DB_USER,
DB_PASS,
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false
]
);
} catch (PDOException $e) {
die("Connection failed: " . $e->getMessage());
}
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
set_flash_message('error', 'Invalid note ID');
header('Location: notes.php');
exit;
}
$note_id = (int) $_GET['id'];
$stmt = $pdo->prepare("SELECT * FROM notes WHERE id = ?");
$stmt->execute([$note_id]);
$note = $stmt->fetch();
if (!$note) {
set_flash_message('error', 'Note not found');
header('Location: notes.php');
exit;
}
$page_title = $note['title'];
require_once 'includes/header.php';
require_once 'includes/topbar.php';
require_once 'includes/sidebar.php';
?>
<div class="container py-4">
<div class="row">
<div class="col">
<div class="card mt-5">
<div class="card-body bg-white text-dark border rounded-2 shadow-md">
<h1 class="mb-3"><?php echo htmlspecialchars($note['title']); ?></h1>
<div class="text-muted mb-4">
<small>Last updated: <?php echo format_date($note['updated_at']); ?></small>
</div>
<div>
<?php echo $note['content']; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php require_once 'includes/footer.php'; ?>