-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckscore.php
43 lines (38 loc) · 1.36 KB
/
checkscore.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
<?php
$uID = $_COOKIE['UserID'];
//echo $uID;
//$pID = $_COOKIE['playerid'];
//echo $pID;
@$pid=$_GET["pid"];
//echo $pid;
@$score=$_GET["score"];
//echo $score;
define('DB_HOST','localhost');
define('DB_USER','root');
define('DB_PASS', '');
define('DB_NAME','basketball');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$sql = "select * from usersperference where UserID = '$uID' and RK='$pid'";
$result = mysqli_query($dbc,$sql);
$rows = mysqli_num_rows($result);
if ($rows) {
$sql_update = "update usersperference set Scores = '$score' where UserID = '$uID' and RK='$pid' limit 1";
if (mysqli_query($dbc,$sql_update)) {
echo "<script LANGUAGE='javascript'>alert('Your preference has been updated!');</script>";
echo "
<script>
setTimeout(function(){window.location.href='players_main.php';},1000);
</script>
";
}
} else {
$sql_insert = "insert into usersperference(UserID,RK,Scores) values ('$uID','$pid','$score')";
if (mysqli_query($dbc, $sql_insert)) {
echo "<script LANGUAGE='javascript'>alert('Your preference has been inserted!');</script>";
echo "
<script>
setTimeout(function(){window.location.href='players_main.php';},1000);
</script>
";
}
}