-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreatePlaylist.php
More file actions
54 lines (43 loc) · 1.21 KB
/
Copy pathcreatePlaylist.php
File metadata and controls
54 lines (43 loc) · 1.21 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
<html>
<head></head>
<?php
$servername = "localhost";
$username = "root";
$password = "";
function create($pname, $trackId, $uname) {
global $servername, $username, $password;
$mysqli = new mysqli($servername, $username, $password, "dbproject");
if (mysqli_connect_errno()) {
die("Connect to db failed: " . "<br>" . mysqli_connect_error() );
}
$position = "SELECT pid from PlaylistInfo Order by pid desc limit 1";
$st = $mysqli->prepare($position);
$st->execute();
$st->bind_result($poss);
$valid = $st->fetch();
$st->close();
$poss++;
$stmt = $mysqli->prepare("INSERT INTO PlaylistInfo (pid, ptitle, pdate, username) VALUES (?, ?, CURRENT_TIMESTAMP, ?)");
$stmt->bind_param('iss', $poss, $pname, $uname);
$stmt->execute();
$valid = $stmt->fetch();
$stmt->close();
$sql = "INSERT INTO Playlist (pid, trackID, position) VALUES (?, ?, 1)";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param('ii', $poss, $trackId);
$stmt->execute();
$valid = $stmt->fetch();
$stmt->close();
$mysqli->close();
}
?>
<?php
session_start();
$trackId = $_POST['trackId'];
$pname = $_POST['pname'];
$name = $_SESSION['login_user'];
create($pname, $trackId, $name);
?>
<body>
</body>
</html>