I am trying to send two pieces of info to a php. 1-) tent = zuzu 2-) zart = gagi
target php simply echoes what I send so that I can check if it's working. This is the javascript:
function boka ()
{
var mesparam = "tent=zuzu&zart=gagi";
if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}
else {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) {document.getElementById("response").innerHTML=xmlhttp.responseText;} }
xmlhttp.open("POST","/mysite/oxifa/oxifat.php?tent=zuzu&zart=gagi",true);
//xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//xmlhttp.setRequestHeader("Content-length", mesparam.length);
//xmlHttp.setRequestHeader("Connection", "close");
xmlhttp.send(mesparam);
}
This is oxifat.php that recieves the request:
<?php
echo " sign1 <br>";
echo next($_POST);
echo next($_POST);
echo next($_POST);
echo next($_POST);
echo next($_POST);
echo $_POST['tent'];
echo $_POST['zart'];
echo $_REQUEST['tent'];
echo $_REQUEST['zart'];
echo "<br> sign2";
?>
As you can see I've included all sorts of things to echo out whatever is in $_POST but apparently there is nothing there and this is the response I get:
sign1
Notice: Undefined index: tent in C:\wamp\www\mysite\oxifa/oxifat.php on line 16
Notice: Undefined index: zart in C:\wamp\www\mysite\oxifa/oxifat.php on line 17
Notice: Undefined index: tent in C:\wamp\www\mysite\oxifa/oxifat.php on line 18
Notice: Undefined index: zart in C:\wamp\www\mysite\oxifa/oxifat.php on line 19
sign2
three lines about the "setRequestHeader" are in comment status. If I include them, I don't even get sign1. No response. What I figure out from this is everything is OK but I don't seem to understand how to use the post method to pass data to php. How do I do this? I have read everything on the net. I only do not know what "setRequestHeader" is for. One more thing: If I put ?tent=zuzu&zart=gagi at the end of target URL, $_REQUEST thing works. But that's GET and not what I'm trying to do. What is the $_POST's deal?