Hello I'm trying to post data to a database and it's working with get, but not with post.
Here's my javascript:
function updateShout(id)
{
var http = new XMLHttpRequest();
http.open("POST", location.href);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.send("edit="+document.getElementById("EDITM").value+"&id="+id);
return false;
}
I'm making an ajax request to the current page with: index.php?edit=message&id=X
PHP is working fine, but I believe it's something with this line:
http.send("edit="+document.getElementById("EDITM").value+"&id="+id);
PHP (if needed):
if($_SESSION['signedin'])
{
if(!is_blank($_REQUEST['edit'])) //if empty($value) && !is_numeric($value);
{
$id = toNum( $_REQUEST['id'] ); //if(!is_numeric($val)) return -1; return (int)$val;
$msg = htmlentities($_REQUEST['edit']); //secure dis
$query = $db->query("UPDATE shouts SET shout='$msg' WHERE shoutid='$id'");
$db->close();
exit;
}
}
please close.. found my issue. my had name instead of id as "EDITM"