switch ($_POST['submit_button']) { case 'Save Draft and Continue Editing': $myPost->SetValue('status', 'Draft'); $redirect = false; break; case 'Save and Publish': $myPost->SetValue('status', 'Published'); default: break; } // Save the info to the DB if there is no errors if ($myPost->Save()) { // Sync in the Tags $myPostTag = new PostTag(); $myPostTag->SetValue('post_id', $myPost->GetPrimary()); $myPostTag->Sync($myPost->GetValue('tags')); SetAlert('Post Information Saved.', 'success'); // Redirect if needed if ($redirect) { header('location:posts.php'); die; } } } // If Deleting the Page if ($_POST['submit_button'] == 'Delete') { // Get all the form data $myPost->SetValues($_POST); // Remove the info from the DB if ($myPost->Delete()) { // Set status and redirect