-
Notifications
You must be signed in to change notification settings - Fork 3
/
new_music.php
34 lines (31 loc) · 1.3 KB
/
new_music.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
<?php if(!empty($_SESSION['login_admin'])):?>
<?php
include "database.php";
if(isset($_POST["music_name"]) && $_POST["music_name"] != null && $_POST["music_name"] != "" && $_FILES["mp3"]['name'] != "")
{
$name = $_POST["music_name"];
$album_id = (int)($_POST["album_id"]);
$date = date('Y-m-d H:i:s');
$date = str_replace(':','-',$date);
$mp3_name = "mp3/".$date.$_FILES['mp3']['name'];
if($_FILES["image"]["name"] != "")
{
$img_name = "img/track/".$date.$_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'],$img_name);
}
else
{
$img_name = "";
}
echo $mp3_name.'<br>';
$db->query("INSERT INTO `music`(name, image, album_id, mp3) VALUES('$name','$img_name','$album_id','$mp3_name')");
move_uploaded_file($_FILES['mp3']['tmp_name'],$mp3_name);
header("Location:admin_musics.php");
}
else
{
header("Location:admin_musics.php");
}
?>
<?php else:{header("Location: index.php");} ?>
<?php endif; ?>