following is my js
var obj = {};
obj["name"] = uname;
obj["repo"] = repo;
obj["length"] = linelength;
var json = JSON.stringify(obj);
$.ajax({
method: "POST",
url: "example.php",
data: {'data' : json},
success: function(response){
console.log("success");
}
});
and following is my php
<?php
include("connection.php");
if(isset($_POST["data"])){
$myData = $_POST["data"];
$ddata = json_decode($myData);
$name = $ddata->name;
$repo = $ddata->repo;
$length = $ddata->length;
$query = "INSERT INTO user('name', 'repo', 'length') VALUES($name, $repo, $length)";
$db->exec($query);
} ?>
The log is showing success but the data are not getting added in db. Your help will be appreciated