Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Eneuem committed Dec 8, 2023
1 parent 22e4824 commit 7d6cdc9
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 4 deletions.
2 changes: 1 addition & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">PROFILE</a>

<?php if (isset($_SESSION['user_power']) && $_SESSION['user_power'] != 0) : ?>
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">SUPER-ADMIN</a>
<a href="php_bo/main.php" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">SUPER-ADMIN</a>
<?php endif; ?>

<a href="php/logout.php" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">LOGOUT</a>
Expand Down
3 changes: 3 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
case 'home':
include("php/page_main.php");
break;
case 'admin':
include("php_bo/main.php");
break;
default:
include("php/page_main.php");
}
Expand Down
24 changes: 21 additions & 3 deletions php_bo/bo_movie_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@
exit;
}

if (isset($_POST['delete_from_database'])) {
$imdbIdToDelete = $_POST['imdb_id']; // Récupération de l'ID IMDb depuis le formulaire POST

try {
$stmt = $pdo->prepare("DELETE FROM movies WHERE imdb_id = :imdb_id");
$stmt->bindParam(':imdb_id', $imdbIdToDelete); // Utilisation de l'ID récupéré
$stmt->execute();

echo "Film supprimé avec succès de la base de données.";
// Recharger les données après la suppression
$stmt = $pdo->query("SELECT * FROM movies");
$movies = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
echo "Erreur lors de la suppression du film : " . $e->getMessage();
}
}

?>
<!--todelete-->
<script src="https://cdn.tailwindcss.com"></script>
Expand All @@ -23,10 +40,11 @@
<img src="<?php echo htmlspecialchars($movie['poster_url']); ?>" alt="Affiche" class="rounded mb-4">
<h2 class="text-xl font-bold mb-2"><?php echo htmlspecialchars($movie['title']); ?></h2>
<div class="flex justify-between mt-auto">
<a href="view_movie.php?id=<?php echo ($movie['imdb_id']); ?>" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Afficher</a>
<a href="bo_view_movie.php?id=<?php echo htmlspecialchars($movie['imdb_id']); ?>" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Afficher</a>

<form method="post">
<input type="hidden" name="imdb_id" value="<?php echo htmlspecialchars($movie['imdb_id']); ?>">
<button type="submit" name="delete_movie" class="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded">Effacer</button>
<input type="hidden" name="imdb_id" value="<?php echo htmlspecialchars($movie['imdb_id']); ?>">
<button type="submit" name="delete_from_database" class="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded">Effacer</button>
</form>
</div>
</div>
Expand Down
12 changes: 12 additions & 0 deletions php_bo/view_movie.php → php_bo/bo_view_movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
$movieActors = json_decode($movieDetails['actors'], true);
$movieProducers = json_decode($movieDetails['producers'], true); // Si vous avez des données de producteurs
$movieDirectors = json_decode($movieDetails['directors'], true);

if (isset($_POST['delete_from_database'])) {
try {
$stmt = $pdo->prepare("DELETE FROM movies WHERE imdb_id = :imdb_id");
$stmt->bindParam(':imdb_id', $movieId);
$stmt->execute();

echo "Film supprimé avec succès de la base de données.";
} catch (PDOException $e) {
echo "Erreur lors de la suppression du film : " . $e->getMessage();
}
}
?>

<!DOCTYPE html>
Expand Down
33 changes: 33 additions & 0 deletions php_bo/main.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php include"../php/start.php"; ?>
<div class="flex lg:flex-row flex-col">
<!-- Sidebar -->
<div class="w-80 bg-gray-200 text-base-content min-h-screen">
<ul class="p-4">
<li><a href="main.php?page=add" class="block p-2 hover:bg-base-300 rounded">Ajouter film</a></li>
<li><a href="main.php?page=list" class="block p-2 hover:bg-base-300 rounded">Voir liste</a></li>
<li><a href="#" class="block p-2 hover:bg-base-300 rounded">Modifier films</a></li>
<!-- Ajouter d'autres éléments de la barre latérale ici -->
</ul>
</div>

<!-- Contenu principal -->
<div class="flex-1 flex items-center justify-center">
<?php
$page = isset($_GET['page']) ? $_GET['page'] : 'default';

switch($page)
{
case 'add':
include("bo_add_movie.php");
break;
case 'list':
include("bo_movie_list.php");
break;
}
?>
<label for="sidebar-toggle" class="btn btn-primary lg:hidden">Open drawer</label>
</div>
</div>

<!-- Bouton de basculement de la barre latérale pour les petits écrans -->
<input type="checkbox" id="sidebar-toggle" class="hidden">

0 comments on commit 7d6cdc9

Please sign in to comment.