public function savePage()
 {
     $page_id = sanitize($_POST['pageId']);
     $page_js = htmlentities($_POST['pageJS']);
     $page_content = htmlentities($_POST['pageContent']);
     $dbh = new PDO("mysql:host=" . $GLOBALS['db_host'] . ";dbname=" . $GLOBALS['db_db'], $GLOBALS['db_user'], $GLOBALS['db_pass']);
     $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $stmt = $dbh->prepare("select * from pages where PageID = :pageId and PageContent = :pageContent");
     $stmt->execute(array('pageId' => $page_id, "pageContent" => $page_content));
     if ($stmt->rowCount()) {
         // Already exists!
         echo json_error_msg("Already exists");
     } else {
         $stmt = $dbh->prepare("update pages set PageContent = :pageContent, PageJS = :pageJS where PageID = :pageId");
         $stmt->execute(array("pageContent" => $page_content, "pageJS" => $page_js, "pageId" => $page_id));
         if ($stmt->rowCount()) {
             echo json_success_msg("Page Saved Sucessfully");
         } else {
             echo json_error_msg("Page NOT Saved Sucessfully");
         }
     }
 }
 public function logout()
 {
     session_start();
     unset($_SESSION);
     $_SESSION['userID'] = null;
     $_SESSION['userAdminStatus'] = null;
     session_destroy();
     echo json_success_msg("You have sucessfully been logged out!" . $_SESSION['userID']);
 }