redirects work for create and edit
This commit is contained in:
parent
1a5a069844
commit
5a63cc66c5
@ -52,7 +52,6 @@ class NotesController
|
|||||||
$_POST['content'],
|
$_POST['content'],
|
||||||
$_SESSION['user_id']
|
$_SESSION['user_id']
|
||||||
);
|
);
|
||||||
exit();
|
|
||||||
|
|
||||||
if ($note) {
|
if ($note) {
|
||||||
// Redirect to show notes page after successful creation
|
// Redirect to show notes page after successful creation
|
||||||
@ -91,6 +90,6 @@ class NotesController
|
|||||||
{
|
{
|
||||||
$noteId = $_GET['id'];
|
$noteId = $_GET['id'];
|
||||||
$this->notesModel->deleteNote($noteId, $_SESSION['user_id']);
|
$this->notesModel->deleteNote($noteId, $_SESSION['user_id']);
|
||||||
header("Location: ?controller=Notes&page=showNotes");
|
header("Location: ?controller=Notes&page=showNotes&do=showNotes");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,33 +17,5 @@ class WelcomeController
|
|||||||
if ($this->notesModel === null) {
|
if ($this->notesModel === null) {
|
||||||
$this->notesModel = new \ppa\Model\NotesModel();
|
$this->notesModel = new \ppa\Model\NotesModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
||||||
if ($_POST['action'] === 'create_note') {
|
|
||||||
$this->notesModel->createNote(
|
|
||||||
$_POST['title'],
|
|
||||||
$_POST['content'],
|
|
||||||
$_SESSION['user_id']
|
|
||||||
);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
else if ($_POST['action'] === 'update_note') {
|
|
||||||
$this->notesModel->editNote(
|
|
||||||
$_POST['note_id'],
|
|
||||||
$_POST['title'],
|
|
||||||
$_POST['content'],
|
|
||||||
$_SESSION['user_id']
|
|
||||||
);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
else if ($_POST['action'] === 'delete_note') {
|
|
||||||
$this->notesModel->deleteNote(
|
|
||||||
$_POST['note_id'],
|
|
||||||
$_SESSION['user_id']
|
|
||||||
);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
header('Location: ?controller=Notes&page=showNotes&do=showNotes');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,8 @@ function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') {
|
|||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="button"><?php echo $isEditMode ? 'Update Note' : 'Create Note'; ?></button>
|
<button type="submit" class="button"><?php echo $isEditMode ? 'Update Note' : 'Create Note'; ?></button>
|
||||||
</div>
|
</div>
|
||||||
|
<input type="hidden" name="controller" value="Notes">
|
||||||
|
<input type="hidden" name="do" value="createNote">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -62,6 +62,8 @@ function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') {
|
|||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="button"><?php echo $isEditMode ? 'Update Note' : 'Create Note'; ?></button>
|
<button type="submit" class="button"><?php echo $isEditMode ? 'Update Note' : 'Create Note'; ?></button>
|
||||||
</div>
|
</div>
|
||||||
|
<input type="hidden" name="controller" value="Notes">
|
||||||
|
<input type="hidden" name="do" value="editNote">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user