I have a button, when I click this button I want to add $5000 to the player’s cash. It doesn’t work, it won’t update my SQL. Please assist.
<script>
$("#updatecash").click(function() {
$.ajax({
url: "playerupdates.php",
method: "POST",
data: {
amount: "5000"
}
}).done(function(res) {
console.log(res);
//"Updated data successfullyn";
//IF ALL IS OK!!
});
}); </script>
<button id="updatecash">Items here</button>
<?php
include("dbconnect.php");
include("playerchecks.php");
$cashupdate = $_POST['amount'];
$newmoney = $player_money + $cashupdate;
$query = "UPDATE players SET player_money = '$newmoney' WHERE player_username = 'Babak'";
mysql_query($query) or die(mysql_error());
?>