/** * Created by PhpStorm. * User: mithun.alinkil * Date: 07-11-2015 * Time: 13:35 */ require_once 'SQLiteNotesRepository.php'; require_once 'Notes.php'; session_start(); if (!isset($_SESSION['user'])) { header("Location: login.php"); exit; } $noteRepo = new \malinkil\AS3\SQLiteNotesRepository(); $noteId = isset($_GET['id']) ? $_GET['id'] : ''; $notes = $noteRepo->getNoteById($noteId); if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['id'])) { ?> <?php // Came from show page based on id parameter $notes = $noteRepo->getNoteById($_POST['id']); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1">
"></label><br></div> <input type="submit" class="btn btn-primary" value="Save Note"> <strong><a href="index.php">Back to Note List</a></strong> </form> <?php } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['noteId'])) { ?> <?php if ($formIsValid) { ?> <?php //Process valid data and save note update $notesRepo = new \malinkil\AS3\SQLiteNotesRepository(); $notes = $notesRepo->getNoteById($_POST['noteId']); $notes->setNotes($mynotes); $notes->setSubject($subject); $notes->setAuthor($author); $createdDate = date('d M Y -g:i:s A'); $notes->setDatecr($createdDate); $notesRepo->saveNote($notes); ?> <title>Update Note</title> <h1>Note Updated</h1> <p><a href="index.php">Back to Note List</a></p> </body> </html> <?php } else { ?>