-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminlogout.php
More file actions
executable file
·143 lines (131 loc) · 6.42 KB
/
Copy pathadminlogout.php
File metadata and controls
executable file
·143 lines (131 loc) · 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Movie Management</title>
<link rel="stylesheet" href="admin.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.0/css/all.min.css" integrity="sha512-9xKTRVabjVeZmc+GUW8GgSmcREDunMM+Dt/GrzchfN8tkwHizc5RP4Ok/MXFFy5rIjJjzhndFScTceq5e6GvVQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
<div id="wrapper">
<!-- Sidebar -->
<aside id="sidebar">
<div>
<img src="Images/logo12.png" height="110px" width="140px" style="margin: auto; margin-left:70px" alt="Logo" />
<h2 style=" text-align: center;">Admin Panel</h2>
</div>
<nav>
<ul>
<li><a href="adminhome.php"><i class="fa-solid fa-house" style="margin-right:12px"></i>Home</a></li>
<li><a href="adminupload.php" id="addMovieLink" style="margin-right:18px"> <i class="fa-solid fa-clapperboard"></i> Add Movies</a></li>
<li><a href="adminlistalluser.php" style="margin-right:18px"><i class="fa-solid fa-users"></i> List All Users</a></li>
<li><a href="adminlogout.php"> <i class="fa-solid fa-right-from-bracket"></i> Logout</a></li>
</ul>
</nav>
</aside>
<!-- Main Content -->
<div class="logout-container" style="margin: auto;">
<button style="
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #ff4d4f;
color: white;
font-size: 16px;
font-weight: bold;
cursor: pointer;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: background-color 0.3s, transform 0.2s;
"
class="logout-btn" onclick="window.location.href='login.php'">
Logout
</button>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Load movies from the backend API
document.getElementById('loadMovies').addEventListener('click', () => {
fetch('https://moviewatch-atullyamzn.42web.io/movie/unzipit/movie/RestAPI.php')
.then(response => response.json())
.then(data => {
const movieList = document.getElementById('movieList');
movieList.innerHTML = ''; // Clear previous list
data.forEach(movie => {
const div = document.createElement('div');
div.innerHTML = `
<h3>${movie.title}</h3>
<p>${movie.description}</p>
<img src="${movie.image}" alt="${movie.title}" style="max-width: 100%; height: auto;">
<button onclick="deleteMovie(${movie.movie_id})">Delete</button>
`;
movieList.appendChild(div);
});
})
.catch(error => {
console.error('Error loading movies:', error);
});
});
// Function to delete a movie
window.deleteMovie = function(id) {
fetch(`https://moviewatch-atullyamzn.42web.io/movie/unzipit/movie//RestAPI.php?id=${id}`, {
method: 'DELETE'
})
.then(response => response.json())
.then(data => {
alert(data.message);
location.reload(); // Reload the page after deletion
})
.catch(error => {
console.error('Error deleting movie:', error);
});
}
// Handling the form submission to add a movie
document.getElementById('movieForm').addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData();
const title = document.getElementById('title').value;
const duration = document.getElementById('duration').value;
const availableTime = document.getElementById('available_time').value.split(',');
const genere = document.getElementById('genere').value;
const description = document.getElementById('description').value;
const director = document.getElementById('director').value;
const cast = document.getElementById('cast').value;
const releaseon = document.getElementById('releaseon').value;
const image = document.getElementById('image').files[0];
const vid = document.getElementById('vid').files[0];
// Validation for required fields
if (!title || !duration || !availableTime || !genere || !description || !director || !cast || !releaseon || !image || !vid) {
alert("All fields are required!");
return;
}
// Append the form data
formData.append('title', title);
formData.append('duration', duration);
formData.append('available_time', JSON.stringify(availableTime)); // Ensure available_time is an array
formData.append('genere', genere);
formData.append('description', description);
formData.append('director', director);
formData.append('cast', cast);
formData.append('releaseon', releaseon);
formData.append('image', image);
formData.append('vid', vid);
// Send form data to the backend
fetch('https://moviewatch-atullyamzn.42web.io/movie/unzipit/movie/RestAPI.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
alert(data.message);
location.reload(); // Reload the page after successful submission
})
.catch(error => {
console.error('Error adding movie:', error);
});
});
});
</script>
</body>
</html>