I am trying to send the score of an application to the database using AJAX.
Here is the application code
var score=count;
$.ajax({
url: 'ajax.php',
type: 'get',
data: {score: score},
success : function(data)
{
alert("Succeed");
}
});
ajax.php
<?php
$score= isset($_POST['score'])? $_POST['score'] : '';
echo $score;
$query=mysql_connect("localhost","admin","");
mysql_select_db("fypdb",$query);
$sqlqury="insert into fypdbtable (score)values('". $_POST['$score']."') where username=($_SESSION['sess_firstname'])");
?>
I want to send the variable score using AJAX to ajax.php and then to fypdb database in fypdbtable
.
In your Ajax code you're setting the type to 'GET' and in your PHP code you're using 'POST'
Use 'GET' or 'POST' in both