exit; } // Load PageManagement Class. require_once 'lib/pm.php'; // Create a new PageManagement instance. $pm = new PageManagement(); // Handle which function gets called. switch ($_REQUEST['func']) { case 'post': // Make sure you're not trying to create when you want to update. if (!empty($_POST['id'])) { $_REQUEST['func'] = 'update'; // break; } else { unset($_POST['func']); $id = $pm->postNewContent($_POST); if ($id) { $message = "Content create."; } else { $message = "Content NOT created. Try again in a few minutes."; } echo json_encode(array("id" => $id, "message" => $message)); break; } case 'update': unset($_POST['func']); $id = $pm->updateContent($_POST); if ($id) { $message = "Content updated."; } else { $message = "Content NOT updated. Try again in a few minutes.";