Exemplo n.º 1
0
        <?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);
            echo $media->title;