static function getMovies() { $sql = 'SELECT mov_id FROM movie;'; $sth = dbConnection()->prepare($sql); $sth->execute(); $fetch = $sth->fetchAll(); $i = 0; $movies = array(); foreach ($fetch as $row) { $movies[$i] = Movies::getMovie($row['mov_id']); $i++; } return $movies; }
function displayDeleteMovie($id) { $m = Movies::getMovie($id); ?> <div class="container"> <div class="well well-lg text-center"> <h2>Supression d'un film</h2> <p> Vous êtes sur le point de supprimer le film : "<?php echo escape($m->title); ?> " de <?php echo escape($m->director); ?> , <?php echo escape($m->year); ?> . </p> <p> Confirmer cette opération ? </p> <form class="form-inline" id='deletemovieform' action='.' method='post'> <input type="hidden" name="id" value="<?php echo $m->id; ?> "/> <div class="form-group"> <a type="submit" class="btn btn-danger" href=".">Annuler</a> <button class="btn btn-primary" type="submit" name="send"> <span class="glyphicon glyphicon-save"></span> Confirmer </button> </div> <input type="hidden" name="action" value="sendDeleteForm"/> </form> </div> </div> <?php }
<?php try { if (isset($_POST["action"])) { if ($_POST["action"] == 'sendLoginForm') { if (isset($_POST["login"]) && isset($_POST["password"])) { $b = Users::loginUser($_POST["login"], $_POST["password"]); echo "<script>alert('hop');</script>"; } } if ($_POST["action"] == 'sendEditForm') { if (isset($_POST["id"])) { if (isset($_FILES['image'])) { if (Movies::insertImage($_FILES["image"])) { Movies::editMovie(new Movie($_POST["id"], $_POST["title"], $_POST["short_description"], $_POST["long_description"], $_POST["director"], $_POST["year"], $_FILES["image"]["name"] == "" ? Movies::getMovie($_POST["id"])->image : $_FILES["image"]["name"])); } } } else { if (isset($_POST["login"])) { Users::editUser(new User($_POST["login"], $_POST["password"], $_POST["firstname"], $_POST["lastname"])); } } } if ($_POST["action"] == 'sendInsertForm') { if (isset($_FILES['image'])) { if (Movies::insertImage($_FILES["image"])) { Movies::insertMovie(new Movie(0, $_POST["title"], $_POST["short_description"], $_POST["long_description"], $_POST["director"], $_POST["year"], $_FILES["image"]["name"])); } } } if ($_POST["action"] == 'sendDeleteForm') {