fetch(); assert_error($parent && $parent['owner'] == $user['id'], "The selected parent does not exist, or you cannot create children for it."); } $note_title = ""; $note_text = ""; $note_public = (isset($parent) ? $parent['public'] : true); if (isset($_POST['title']) && isset($_POST['text'])) { $note_title = esca($_POST['title']); $note_text = esca($_POST['text']); $note_html = Markdown($note_text); $note_public = isset($_POST['public']); if ($note_title == "") { $error = "You must enter a title for your note"; } else { sql("INSERT INTO notes(owner, parent, title, text, text_html, public) ". "VALUES(?, ?, ?, ?, ?, ". ($note_public?'1':'0') . ")", $user['id'], $parentid, escs($note_title), escs($note_text), escs($note_html)); header("Location: view-notes-" . $sql_conn->lastInsertId()); die(); } } $title = "New note"; $fields = array( array("label" => "Title : ", "name" => "title", "value" => $note_title), array("label" => "Public ? ", "name" => "public", "type" => "checkbox", "checked" => $note_public), array("label" => "Text : ", "name" => "text", "type" => "textarea", "value" => $note_text), ); $validate = "Create note"; require("tpl/notes/new.php");