Browse Source

Started to work on high score system

pull/1/head
jrtechs 7 years ago
parent
commit
60b6b2cc5b
3 changed files with 39 additions and 1 deletions
  1. +9
    -1
      games/bamboofield.html
  2. +21
    -0
      games/insertScore.php
  3. +9
    -0
      includes/header.php

+ 9
- 1
games/bamboofield.html View File

@ -270,6 +270,14 @@
context.fillStyle = "rgba(255, 255,255 ,1)";
context.font = "20px Georgia";
context.fillText("You died with a score of: " + score, 250, 325);
document.body.innerHTML += '<form id="dynForm" action="insertScore.php" method="post">\n\
<input type="hidden" name="game_new_score" value=true>\n\
<input type="hidden" name="game" value="1">\n\
<input type="hidden" name="user_id_score" value=" ' + <?php $_SESSION['user_id'] ?> + ' ">\n\
<input type="hidden" name="score_validate" value="' + score + '"></form>';
document.getElementById("dynForm").submit();
}
animate(tic);
}
@ -295,4 +303,4 @@
</script>
<div><canvas id="canvasBF" width="700" height="700"></canvas></div>
<div><input type="submit" name="play" value="Play Game" onclick="this.blur();playBF()"/></div>
<div><input type="submit" name="play" value="Play Game" onclick="this.blur();playBF()"/></div>

+ 21
- 0
games/insertScore.php View File

@ -0,0 +1,21 @@
<?php
//5-16-17
if(isset($_POST['game_new_score']))
{
$i_game = mysqli_real_escape_string($dbc, trim($_POST['game']));
$i_user_id = mysqli_real_escape_string($dbc, trim($_POST['user_id_score']));
$i_score = mysqli_real_escape_string($dbc, trim($_POST['score_validate']));
$q = "insert into scores(game, user_id, score) values('$i_game','$i_user_id','$i_score')";
$r = mysqli_query($dbc, $q);
echo("<meta http-equiv='refresh' content='1'>");
}
?>

+ 9
- 0
includes/header.php View File

@ -39,6 +39,15 @@
}
}
try
{
include('games/insertScore.php');
}
catch (Exception $ex)
{
}
echo '<!DOCTYPE html>
<html>

|||||||
x
 
000:0
Loading…
Cancel
Save