Add "Add Movie" function

This commit is contained in:
2026-04-13 02:18:56 +02:00
parent a41850bdc7
commit 9acd0f36a2
3 changed files with 183 additions and 40 deletions
+7 -32
View File
@@ -1,4 +1,3 @@
<?php include 'RequestHandler.php'; ?>
<!DOCTYPE html>
<html lang="fr">
<head>
@@ -9,43 +8,19 @@
<body class="bg-slate-900 text-white p-8">
<div class="max-w-4xl mx-auto">
<h1 class="text-3xl font-bold mb-8 text-blue-400 text-center">Rechercher un film ou une série</h1>
<h1 class="text-3xl font-bold mb-8 text-blue-400 text-center">WatchGether</h1>
<form method="GET" class="flex gap-2 mb-10">
<input type="text" name="q" placeholder="Titre du film..."
<div class="flex gap-2 mb-10">
<input type="text" id="searchInput" placeholder="Chercher un film ou une série..."
class="flex-grow p-4 rounded-lg bg-slate-800 border border-slate-700 focus:outline-none focus:border-blue-500">
<button type="submit" class="bg-blue-600 px-8 py-4 rounded-lg font-bold hover:bg-blue-500 transition">
<button onclick="performSearch()" class="bg-blue-600 px-8 py-4 rounded-lg font-bold hover:bg-blue-500 transition">
Chercher
</button>
</form>
<div class="grid grid-cols-2 md:grid-cols-4 gap-6">
<?php
if (isset($_GET['q']) && !empty($_GET['q'])) {
$results = searchMovie($_GET['q']);
foreach ($results['results'] as $item) {
// On ne prend que les films ou séries qui ont une affiche
if (isset($item['poster_path'])) {
$title = isset($item['title']) ? $item['title'] : $item['name'];
$poster = "https://image.tmdb.org/t/p/w500" . $item['poster_path'];
$date = isset($item['release_date']) ? substr($item['release_date'], 0, 4) : (isset($item['first_air_date']) ? substr($item['first_air_date'], 0, 4) : '');
echo "
<div class='bg-slate-800 rounded-xl overflow-hidden border border-slate-700 hover:scale-105 transition-transform cursor-pointer'>
<img src='$poster' alt='$title' class='w-full h-auto'>
<div class='p-3'>
<h3 class='font-bold text-sm truncate'>$title</h3>
<p class='text-xs text-gray-400'>$date</p>
<button class='mt-2 w-full bg-green-600 text-xs py-1 rounded hover:bg-green-500'>+ Ajouter</button>
</div>
</div>";
}
}
}
?>
</div>
<div id="resultsGrid" class="grid grid-cols-2 md:grid-cols-4 gap-6"></div>
</div>
<script src="js/index.js"></script>
</body>
</html>