<section id="head-bar"> <?php include_once 'navbar.php'; ?> </section> <div class="container"> <h1>My Watchlist</h1> <?php if (isset($_SESSION['authenticated_user'])) { require_once 'watchlist.php'; require_once 'mediapost.php'; $watchlist = new Watchlist(); $post = new MediaPost(); if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (!empty($_POST['title'])) { $media_id = $post->getMediaIdByTitle($_POST['title']); $watchlist->storeListMedia($_SESSION['authenticated_user'], $media_id); } } else { if ($_SERVER['REQUEST_METHOD'] === 'GET') { if (!empty($_GET['remove_media'])) { $media_id = $_GET['remove_media']; $watchlist->removeMediaFromWatchlist($_SESSION['authenticated_user'], $media_id); } } } $list_items = $watchlist->getWatchlistForUser($_SESSION['authenticated_user']); if ($list_items) { while ($list_item = $list_items->fetch_object()) { echo '<div class="well"><div class="page-header"><h3>'; $media = $post->getMediaById($list_item->media);
</section> <?php if (isset($_SESSION['authenticated_user'])) { require_once 'mediapost.php'; require_once 'user.php'; $error = ""; $new_media = false; if (!empty($_POST['title']) && !empty($_POST['rating'])) { $user = new User(); $post = new MediaPost(); $from_user = $_SESSION['authenticated_user']; $title = $_POST['title']; $rating = $_POST['rating']; $comment = $_POST['comment']; $date_created = date("Y-m-d H:i:s"); $media = $post->getMediaIdByTitle($title); if (!$media) { $media = $post->storeMedia($title); $new_media = true; } if ($_POST['review_type'] == 'private') { $email = $_POST['username']; $to_user = $user->getIdByEmail($email); if ($to_user) { $post->storeRecommendation($from_user, $to_user, $media, $rating, $comment, $date_created); } else { $error = "User with email did not exist"; } } else { $post->storePublicReview($from_user, $media, $rating, $comment, $date_created); }