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]; $strContent = $varRow["content"]; $strLocation = $varRow["location"]; $strVisibility = $varRow["visibility"]; } if (Request::posts("location", "content", "visibility")) { $strLocation = Request::getPosted("location"); $strContent = Request::getPosted("content"); $strVisibility = Request::getPosted("visibility"); if ($strId == null || strlen($strId) < 1) { $c->query( "INSERT into posts (username, content, location, visibility) values (?, ?, ?, ?)", $varUser["username"], $strContent, $strLocation, $strVisibility); $strId = $c->query("get_last_post.sql")[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 content = ?, location = ?, visibility = ?, updated = current_timestamp where id = ?", $strContent, $strLocation, $strVisibility, $strId); BootstrapRender::message("Post saved.", "success"); Respond::redirect("/post/{$strId}"); } ?>