-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_note.php
More file actions
135 lines (107 loc) · 5.63 KB
/
edit_note.php
File metadata and controls
135 lines (107 loc) · 5.63 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
include_once('includes/config.php'); // Ensure DB connection
include_once("get-note.php");
if(isset($_POST["update_note"])){
$noteID = htmlspecialchars(trim($_POST["id"]));
$noteTitle = htmlspecialchars($_POST["note_title"]);
$noteMeditations = htmlspecialchars($_POST['meditations']);
$promises = htmlspecialchars($_POST['promises']);
$principle = htmlspecialchars($_POST['principles']);
$convenants = htmlspecialchars($_POST['convenants']);
$memoryVerse = htmlspecialchars($_POST['memory_verse']);
$noteContent = htmlspecialchars($_POST['note_content']);
if (empty($noteTitle) || empty($noteContent)) {
echo $noteTitle;
echo $noteContent;
$message = "Title / Note content is missing";
$alertType = "danger";
}else{
// Update note in the database:::
$updateNote = "UPDATE `bible-study` SET `noteTitle`= ?,`noteContent`= ? ,`meditations`= ? ,`promises`= ? ,`principle`= ? ,`convenants`= ?,`memoryVerse`= ?";
$updateNoteStmt = $conn->prepare($updateNote);
$updateNoteStmt->bind_param("sssssss", $noteTitle, $noteContent, $noteMeditations, $promises, $principle, $convenants, $memoryVerse);
if($updateNoteStmt->execute()){
$message = "Sucessfully updated the Note🏅🏅🏅";
$alertType = "success";
// header("Location: notes.php", true, 400);
// exit;
}else{
$message = "Failed to update the note. Error: " . $updateStmt->error;
$alertType = "danger";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bible Study | View Note</title>
<link rel="stylesheet" href="assets/bootstrap-5.3.3/dist/css/bootstrap.css">
<link rel="stylesheet" href="assets/bootstrap-5.3.3/dist/css/bootstrap.min.css">
<meta name="description"
content="A small web app for reading and keeping notes when you study your Bible(I built this for myself though)">
<link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="assets/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link href="assets/boxicons/css/boxicons.css" rel="stylesheet">
<link href="assets/boxicons/css/boxicons.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/style.css">
</head>
<body >
<?php require_once("nav.php"); ?>
<div class="container my-5" style="padding-bottom:10px;">
<h2 class="fw-bold" >Edit Note</h2>
<!-- Display alert message when successfully updating the notes and its contents in the DBase -->
<!-- Display Alert Message -->
<?php if (!empty($message)): ?>
<div class="alert alert-<?= $alertType ?> alert-dismissible fade show" role="alert">
<?= htmlspecialchars($message) ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php endif; ?>
<!-- Edit Form -->
<form method="POST" action="">
<input type="hidden" name="id" value="<?= htmlspecialchars($noteID); ?>"> <!-- Hidden input for ID -->
<!-- Title of the note is picked here -->
<div class="mb-3">
<label for="noteTitle" class="form-label">Note Title</label>
<input type="text" class="form-control" id="noteTitle" name="note_title" value="<?= htmlspecialchars($noteTitle); ?>" required>
</div>
<!-- Meditations -->
<div class="mb-3">
<label for="meditations" class="form-label">Meditations</label>
<input type="text" class="form-control" id="meditations" name="meditations" value="<?= htmlspecialchars($noteMeditations); ?>" required>
</div>
<!-- Promises -->
<div class="mb-3">
<label for="promises" class="form-label">Promises</label>
<input type="text" class="form-control" id="promises" name="promises" value="<?= htmlspecialchars($promises); ?>" required>
</div>
<!-- Principles -->
<div class="mb-3">
<label for="principles" class="form-label">Principles</label>
<input type="text" class="form-control" id="principles" name="principles" value="<?= htmlspecialchars($principle); ?>" required>
</div>
<!-- Convenants -->
<div class="mb-3">
<label for="convenants" class="form-label">Convenants</label>
<input type="text" class="form-control" id="convenants" name="convenants" value="<?= htmlspecialchars($convenants); ?>" required>
</div>
<!-- MemoryVerse -->
<div class="mb-3">
<label for="memoryVerse" class="form-label">MemoryVerse</label>
<input type="text" class="form-control" id="memoryVerse" name="memory_verse" value="<?= htmlspecialchars($memoryVerse); ?>" required>
</div>
<div class="mb-3">
<label for="noteContent" class="form-label">Note Content</label>
<textarea class="form-control" id="noteContent" name="note_content" rows="10" required><?= htmlspecialchars($noteContent); ?></textarea>
</div>
<button type="submit" name="update_note" class="btn btn-custom btn-dark">Update Note</button>
</form>
</div>
</div>
</body>
<script src="assets/bootstrap-5.3.3/dist/js/bootstrap.bundle.js"> </script>
<script src="assets/bootstrap-5.3.3/dist/js/bootstrap.bundle.min.js"> </script>
</html>