} // title must not be empty -> space if (!isset($_POST['title'])) { $title = ' '; } else { $title = $_POST['title']; } if (!isset($_POST['text'])) { $text = ''; } else { $text = $_POST['text']; } //construct note $note = new note($arg_id, $title, $text); // save the note if (!$manager->write_note($note)) { echo '{"error": 200, "message": "Could not write the note."}'; die; } echo '{"id": ', $arg_id, '}'; //## Read a note ##// } elseif ("read" == $arg_action) { // return error if 'id' is not set if (!isset($_POST['id']) || $_POST['id'] == '') { echo '{"error": 301, "message": "\'id\' must be set for action (read)."}'; die; } else { $arg_id = $_POST['id']; } // read note $manager->read_note($arg_id);