Пример #1
0
<?php

include '../common.inc.php';
ini_set("file_uploads", "On");
if (!isset($_SESSION)) {
    session_start();
}
//If a user is not logged in, kick them out of this page
if (!is_logged_in()) {
    header('Location: index.php', 501);
}
//Check the request type
if (isset($_POST['submit'])) {
    //Grab the values from the request, validate and save to DB then redirect to movies page
    if (isset($_POST['genre']) && isset($_POST['title']) && isset($_POST['date']) && isset($_POST['score']) && isset($_POST['imdb_id']) && isset($_FILES['poster'])) {
        $operation = add_movie($_POST['genre'], $_POST['title'], $_POST['date'], $_POST['score'], $_POST['imdb_id'], $_FILES['poster']);
    }
}
echo $twig->render('add_movie.html.twig', array('is_logged_in' => is_logged_in(), 'user' => get_user_from_session(), 'genre_ids' => get_movie_genres()));
Пример #2
0
<?php

include '../common.inc.php';
if (!isset($_SESSION)) {
    session_start();
}
//If a user is not logged in, kick them out of this page
if (!is_logged_in()) {
    header('Location: index.php', 501);
}
//Check the request type
if (isset($_POST['submit'])) {
    //Form is being submitted
    $errors = array();
    $messages = array();
    //genre, score, title, date, movie_id
    update_movie($_POST['movie_id'], $_POST['genre'], $_POST['score'], $_POST['title'], $_POST['date'], $_POST['movie_id']);
    header("Location: movies.php");
} else {
    //Pull the values from the database
    if (isset($_GET['movie_id'])) {
        echo $twig->render('edit_movie.html.twig', array('is_logged_in' => is_logged_in(), 'user' => get_user_from_session(), 'genre_ids' => get_movie_genres(), 'movie' => get_movie_by_id($_GET['movie_id'])));
    } else {
        header("Location: index.php?error=invalid_movie_id");
    }
}
Пример #3
0
<?php

include '../common.inc.php';
if (!isset($_SESSION)) {
    session_start();
}
if (!is_logged_in()) {
    header('Location: index.php');
} else {
    echo $twig->render('profile.html.twig', array('is_logged_in' => is_logged_in(), 'user' => get_user_from_session()));
}