I have a mysql table with 'user_name'
and 'user_round'
. I want the 'user_round' to be set to whatever the value of 'Level'
(this is a javascript variable). My code brings up errors like POST 404 not found. Here is what I have:
<script type="text/javascript" src="jQuery.js"></script>
var <?php echo $_SESSION['user_name']; ?>; //Without this I get username not defined error?
var Level = 1;
function Fail() {
$.ajax({
type: "POST",
url: "phpfiles/savestage.php",
data: {
name: '<?php echo $_SESSION['user_name']; ?>',
stage: Level
},
success: function() {
console.log("Finished uploading stage");
}
});
Here is my php page:
<?php
include 'connect.php';
$sql="INSERT INTO DB NAME (user_round, user_name) VALUES ('$stage', '$name')";
$result = mysql_query($sql, $cn) or
die(mysql_error($cn));
?>