i have a problem with an ajax request and a read/write froma database.
I have this code to submit a form to a database:
$(document).ready(function(){
$('#myForm').on('submit',function(e) {
$.ajax({
url:'save.php',
type:'POST',
});
e.preventDefault(); //=== To Avoid Page Refresh and Fire the Event "Click"===
});
});
and i have the save.php file into the same fold with this code:
<?php
include('dbconnection.php');
$Name= $_POST['Name'];
$surname= $_POST['surname'];
$Value= $_POST['Value'];
$sql = "INSERT INTO `results`(`Name`, `surname`, `Value`) VALUES('$Name', '$surname','$Value')";
$retval = mysql_query( $sql );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
?>
the only problem is that the values is not saved inside the db.. What am i doing wrong?