I need to update a database using AJAX so don't have my page be reloaded. I can't find what's wrong and unexpectedly I get a success message back but a database doesn't get updated.
JS:
$('.start-time-class').submit(function() {
var startTime = "11:30";
var projectID = 17;
var userID = 2;
$.ajax({
url:'functions/starttime.php',
data:{startTime:startTime,projectID:projectID,userID:userID}, // pass data
dataType:'json',
success:function(){
// something
}
});
});
PHP:
$con = mysqli_connect('localhost','smt','smt','smt');
if (!$con)
{
die('Could not connect: ' . mysqli_error($con));
}
$startTime = $_GET['startTime'];
$projectID = $_GET['projectID'];
$userID = $_GET['userID'];
mysqli_select_db($con,"ajax_demo");
$sql = "INSERT INTO 'uc_project_time'('userID', 'projectID', 'startTime') VALUES (". $userID .", ". $projectID .", ". $startTime .")";
$result = mysqli_query($con,$sql);
mysqli_close($con);