-
Notifications
You must be signed in to change notification settings - Fork 0
/
approve_songs.php
100 lines (95 loc) · 3.51 KB
/
approve_songs.php
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
<?php
require_once 'config.php';
require_once 'functions.php';
if (!isLoggedIn() || $_SESSION['user_type'] != 'Admin') {
redirect('login.php');
}
// Fetch songs pending approval
$songs_pending_approval = [];
$sql = "SELECT s.id, s.title, s.URL, s.Release_date, s.language, s.details, u.F_name, u.L_name
FROM Song s
JOIN User u ON s.artist_id = u.id
WHERE s.approval = 0"; // Only select songs that are not approved
if ($stmt = mysqli_prepare($conn, $sql)) {
if (mysqli_stmt_execute($stmt)) {
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result)) {
$songs_pending_approval[] = $row;
}
}
mysqli_stmt_close($stmt);
}
mysqli_close($conn);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Approve Songs - Music Streaming Platform</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="sidebar">
<div class="logo">Musicfy</div>
<nav>
<ul>
<li><a href="dashboard.php">Home</a></li>
<li><a href="profile.php">Profile</a></li>
<li><a href="approve_songs.php">Approve Songs</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</nav>
</div>
<div class="main-content">
<h1>Approve Songs</h1>
<form action="approve_songs_action.php" method="post">
<table>
<thead>
<tr>
<th>Title</th>
<th>Artist</th>
<th>Details</th>
<th>Release Date</th>
<th>Language</th>
<th>Audio</th>
<th>Approve</th>
<th>Reject</th>
</tr>
</thead>
<tbody>
<?php if (!empty($songs_pending_approval)): ?>
<?php foreach ($songs_pending_approval as $song): ?>
<tr>
<td><?php echo htmlspecialchars($song['title']); ?></td>
<td><?php echo htmlspecialchars($song['F_name'] . ' ' . $song['L_name']); ?></td>
<td><?php echo htmlspecialchars($song['details']); ?></td>
<td><?php echo htmlspecialchars($song['Release_date']); ?></td>
<td><?php echo htmlspecialchars($song['language']); ?></td>
<td>
<audio controls>
<source src="<?php echo htmlspecialchars($song['URL']); ?>" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</td>
<td>
<button type="submit" name="approve" value="<?php echo htmlspecialchars($song['id']); ?>">Approve</button>
</td>
<td>
<button type="submit" name="reject" value="<?php echo htmlspecialchars($song['id']); ?>">Reject</button>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="8">No songs pending approval.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</form>
</div>
</div>
</body>
</html>