-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_songs.php
More file actions
25 lines (19 loc) · 796 Bytes
/
add_songs.php
File metadata and controls
25 lines (19 loc) · 796 Bytes
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
<?php
//open connection to mysql db
$connection = mysqli_connect("localhost","TopJamAdmin","topjam","TopJam") or die("Error " . mysqli_error($connection));
$jsondata = file_get_contents('php://input');
$data = json_decode($jsondata, true);
$title = $data['title'];
$artist = $data['artist'];
$album = $data['album'];
$votes = 0;
$lobby = $data['lobby'];
$sql = "INSERT INTO Songs(title, artist, album, votes, lobby)
VALUES('$title', '$artist', '$album', '$votes', '$lobby')";
if(!mysqli_query($connection, $sql))
{
die('Error : ' . mysqli_error());
}
$array = array('title' => $title, 'artist' => $artist, 'album' => $album, 'votes' => $votes, 'lobby' => $lobby);
echo json_encode($array);
?>