function newArticle() { $results = array(); $results['pageTitle'] = "New Thing"; $results['formAction'] = "newArticle"; if (isset($_POST['saveChanges'])) { // User has posted the article edit form: save the new article $article = new Article(); $article->storeValues($_POST); $article->insert(); if (isset($_FILES['image'])) { $article->storeUploadedImage($_FILES['image']); } header("Location: admin.php?status=changesSaved"); } elseif (isset($_POST['cancel'])) { // User has cancelled their edits: return to the article list header("Location: admin.php"); } else { // User has not posted the article edit form yet: display the form $results['article'] = new Article(); require TEMPLATE_PATH . "/admin/editArticle.php"; } }