title: Undefined _POST variable when using XMLHttpRequest()
body: <p>I am trying to use Ajax to insert data into database with POST method. But php can not recognize the post variables.  </p>
  
  <p>ajax:  </p>
  
  <pre><code>function createUser() {
  var _id=document.getElementById('new_id').value;
  var _name=document.getElementById('new_name').value;
  var params = "id="+_id+"&amp;name="+_name;
  if (window.XMLHttpRequest) {
      // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp = new XMLHttpRequest();
  } else {
      // code for IE6, IE5
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  //xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlhttp.onreadystatechange = function() {
      console.log(xmlhttp);
      if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
          if(xmlhttp.responseText=="")
              alert("New User is created!");
          else
              document.body.innerHTML=xmlhttp.responseText;
      }
  };
  xmlhttp.open("POST","resource/create_profile.php",true);
  xmlhttp.send(params);
  }  
  </code></pre>
  
  <p>php:  </p>
  
  <pre><code>&lt;?php
  $id = $_POST["id"];
  $name = $_POST["name"];  
  $conn = oci_connect(....);  
  $query = "....";  
  $result = oci_parse($conn, $query);
  oci_execute($result);
  oci_close($conn);
  ?&gt;  
  </code></pre>
  
  <p>if i uncomment the request header content type then nothing happens, no error is shown. if i comment it then php shows error. i am giving a screenshot.  </p>
  
  <p><a href="http://imgur.com/CdKO84V" rel="nofollow">http://imgur.com/CdKO84V</a>  </p>
  
  <p>what am i supposed to do? if i use get method then it is working good but i can not use it since i need to upload file.</p>