You'll have to name the members of your JavaScript formdata
-object the same as the names of the keys you use in the PHP $_POST
array.
So in formdata.append( name, value );
and $value = $_POST['name'];
, "name" has to match in both your JavaScript en PHP code:
JavaScript:
function upd() {
var description = document.getElementById("description").value;
// etc...
var formdata = new FormData();
formdata.append("description",description);
// etc...
var xhr = new XMLHttpRequest();
xhr.open("POST","update.php",true);
xhr.send(formdata);
}
PHP:
$description = $_POST['description']; // So not: $_POST['descrip']
$description = mysqli_real_escape_string($con,$description);
// etc...
$updateQuery = "UPDATE items SET descrip='$description' ...";
// etc...
BTW, what's the problem with using jQuery? With jQuery you could simply do:
Using jQuery:
function upd() {
var desc = $("#description").val();
// etc...
$.post("update.php", {
description: desc // The left side of the colon has to match $_POST['description']
// etc...
}, function(response) {
// Optional: Do something when de call is finished
console.info("Response = " + response);
}
});
}
For more info you can visit jquery.com