-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertRating.php
More file actions
34 lines (27 loc) · 786 Bytes
/
insertRating.php
File metadata and controls
34 lines (27 loc) · 786 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
26
27
28
29
30
31
32
33
34
<?php
$servername = "localhost";
$username = "root";
$password = "";
function insertRating($rate, $uname, $trackID) {
global $servername, $username, $password;
$mysqli = new mysqli($servername, $username, $password, "dbproject");
if (mysqli_connect_errno()) {
die("Connect to db failed: " . "<br>" . mysqli_connect_error() );
}
$stmt = $mysqli->prepare("INSERT INTO Ratings (username, trackID, rating) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $uname, $trackID, $rate);
$stmt->execute();
$valid = $stmt->fetch();
$stmt->close();
$mysqli->close();
}
?>
<?php
session_start();
echo "<p> Playing! </p>";
$rate = $_POST['rate'];
$id = $_POST['id'];
#$name = $_POST['name'];
$name = $_SESSION['login_user'];
insertRating($rate, $name, $id);
?>