-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmanageplaylist.php
147 lines (135 loc) · 2.74 KB
/
manageplaylist.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
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
144
145
146
147
<!DOCTYPE html>
<html>
<head>
<title>Playlist</title>
<!-- <link rel="stylesheet" type="text/css" href="css.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style type="text/css">
h2{
text-align: center;
color: white;
font-weight: bold;
}
p{
color: white;
font-size: 24px;
}
a:link, a:visited {
background-color: black;
color: white;
padding: 5px 5px;
text-align: center;
text-decoration: none;
display: inline-block;
border-radius: 10px;
}
.manage{
background-color: black;
color: white;
padding: 10px 15px;
width: 10%;
text-decoration: none;
display: inline-block;
transition: width 0.4s;
margin-bottom: 7px;
}
h2{
text-align: center;
color: white;
font-weight: bold;
}
</style> -->
</head>
<body>
<?php
include('dbcon.php');
session_start();
$uid=$_SESSION['id'];
if(isset($_GET['delete']))
{
$pid=$_GET['pid'];
$qry="DELETE FROM `playlists` WHERE `pid`='$pid'";
$run=mysqli_query($con,$qry);
if($run)
{
?>
<script>
alert('Playlist deleted successfully!');
window.history.go(-2);
</script>
<?php
}
else
{
?>
<script>
alert('Failed to delete playlist!!');
window.history.go(-2);
</script>
<?php
}
}
else if(isset($_GET['rename']))
{
$pid=$_GET['pid'];
if($_GET['rename']==1)
{
?>
<form action="manageplaylist.php?rename=2&pid=<?php echo $pid;?>" method="post">
Enter new name for playlist: <input type="text" name="newname" required>
<input type="submit" name="submit" value="Rename">
</form>
<?php
}
else
{
$newname=$_POST['newname'];
$qry="UPDATE `playlists` SET `pname`='$newname' WHERE `pid`='$pid'";
$run=mysqli_query($con,$qry);
if($run)
{
?>
<script>
alert('Playist renamed Successfully!!');
window.history.go(-2);
</script>
<?php
}
else
{
?>
<script>
alert('Failed to rename playlist!!');
window.history.go(-2);
</script>
<?php
}
}
}
else
{
$qry="SELECT * FROM `playlists` WHERE `uid`='$uid'";
$run=mysqli_query($con,$qry);
$row=mysqli_num_rows($run);
if($row)
{
?>
<h2>Your Playlists</h2><br><br>
<?php
while($data=mysqli_fetch_assoc($run))
{
?>
<br>
<a class="manage" href="showplaylist.php?pid=<?php echo $data['pid'];?>"><?php
echo " ".$data['pname'];
?></a>
<a href="manageplaylist.php?rename=1&pid=<?php echo $data['pid'];?>"><i class="fa fa-pencil" aria-hidden="true" style="font-size: 20px;" title="Rename"></i>Rename</a>
<a href="manageplaylist.php?delete=1&pid=<?php echo $data['pid'];?>"><i class="fa fa-minus-square" aria-hidden="true" style="font-size: 20px;" title="Delete"></i>Delete</a>
<?php echo " ";?>
<?php
}
}
}
?>
</body>
</html>