Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $servername = "localhost";
- $username = "myUser";
- $password = "myPass";
- $dbname = "myDBname";
- $cash_amount = $_SESSION['cash_amount'];
- // Create connection
- $userid = $_SESSION['id'];
- // You must enter the user's id here. /
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- // Fetch the existing value of the cash_amount against that particular user here. You can use the SELECT cash_amount from users where userid = $userid
- $_SESSION['cash_amount'] -= 0.05;
- $newAmount = $cash_amount - 0.05;
- $sql = "UPDATE users SET cash_amount = $newAmount WHERE id = $userid";
- $result = $conn->query($sql);
- if($result)
- {
- echo "5 cents have been subtracted!";
- }
- else
- {
- echo mysqli_error($conn);
- session_start();
- session_unset();
- session_destroy();
- }
- $conn->close();
- ?>
- function countdownEnded() {
- //make serverscreen dissapear
- document.getElementById('serverScreenWrapper').style.display = 'none';
- document.getElementById('serverScreenWrapper').style.opacity = '0';
- document.getElementById("cashOutNumTwo").style.right = '150%';
- document.getElementById("cashOutNumOne").style.right = '150%';
- //start Timer
- setInterval(gameTimer.update, 1000);
- //make player move again
- socket.emit('4');
- socket.emit('6');
- //make game appear
- document.getElementById('gameAreaWrapper').style.opacity = 1;
- //play sound
- document.getElementById('spawn_cell').play();
- //cut 5 cents from account - php function
- $.ajax({
- type: "POST",
- url: 'http://cashballz.net/game/5game/subtract5.php',
- data: { },
- success: function (data) {
- alert(data);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement