Example #1
0
     //            88  `8D 88'     88      88'     `~~88~~' 88'       d8P  Y8 .8P  Y8. 88'YbdP`88 88'YbdP`88 88'     888o  88 `~~88~~'
     //            88   88 88ooooo 88      88ooooo    88    88ooooo   8P      88    88 88  88  88 88  88  88 88ooooo 88V8o 88    88
     //            88   88 88~~~~~ 88      88~~~~~    88    88~~~~~   8b      88    88 88  88  88 88  88  88 88~~~~~ 88 V8o88    88
     //            88  .8D 88.     88booo. 88.        88    88.       Y8b  d8 `8b  d8' 88  88  88 88  88  88 88.     88  V888    88
     //            Y8888D' Y88888P Y88888P Y88888P    YP    Y88888P    `Y88P'  `Y88P'  YP  YP  YP YP  YP  YP Y88888P VP   V8P    YP
 } else {
     if (isset($_POST['delete'])) {
         require_once MODEL_GUEST_BOOK;
         require_once MODEL_USER;
         session_start();
         // Get the user object
         $user = $_SESSION['user'];
         // Store the comment ID
         $comm_ID = $_POST['userComment'];
         // Get the comment and store it in a variable ( Will be an associative array )
         $comment = GuestBook::getComment($comm_ID);
         GuestBook::deleteComment($comment);
         // Count user comments for view and store it back into the session
         $user->countUserComments();
         $_SESSION['user'] = $user;
         // Provide the user a message
         $_SESSION['userMessage'] = "Your comment has been deleted!";
         header('HTTP/1.1 302 Redirect');
         header('Location: ' . INDEX_REDIRECT);
     } elseif (isset($_POST['cancel'])) {
         session_start();
         // Unset the session to change the view
         if (isset($_SESSION['editComment'])) {
             unset($_SESSION['editComment']);
         }
         // User cancelled an action so refresh the page