0) { $strVerb = "Edit"; $varRows = $c->query("SELECT * from posts where id = ?", $strId); if (count($varRows) !== 1) { BootstrapRender::message("Zero or more than one row returned", "danger"); Respond::redirect("/post"); } $varRow = $varRows[0]; $strPath = $varRow["path"]; $strContent = $varRow["content"]; } if (Request::posts("path", "content")) { $strPath = Request::getPosted("path"); $strContent = Request::getPosted("content"); if ($strId == null || strlen($strId) < 1) { $c->query( "INSERT into posts (email, path, content) values (?, ?, ?)", $varUser["email"], $strPath, $strContent); $strId = $c->query("SELECT * from posts where rowid = last_insert_rowid()")[0]["id"]; } if (strlen($strContent) < 1) { $c->query("DELETE from posts where id = ?", $strId); BootstrapRender::message("Post deleted successfully.", "success"); Respond::redirect("/post"); } $c->query( "UPDATE posts set path = ?, content = ?, updated = current_timestamp where id = ?", $strPath, $strContent, $strId); Respond::redirect("/post/{$strId}"); } ?>