title: $_POST var not populated instead $HTTP_RAW_POST_DATA takes data
body: <p>i use this function in <code>javascript</code> to communicate with the server php script:</p>
  
  <pre><code>    ajax = function( url, ready, json=null, method = 'post') {
      var response, request = xhr();
      request.open( method, url, true );
      request.onreadystatechange = function() {
          if( request.readyState == 4 ) {
              if( typeof ready == 'function' ){
                  return ready( request );
              } else {    return JSON.parse( request.responseText );}
          } 
      }
      if(json !== null){
          request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
          return request.send( JSON.stringify( json ) );
      }else { return request.send( null );}
  }
  </code></pre>
  
  <p>i made the <code>XMLHttpRequest</code> after i open the connection using <code>post method</code>.
  i also set the <code>setRequestHeader</code> to parse <code>JSON: ("Content-Type", "application/json;charset=UTF-8");</code> and i used this function to colect <code>data</code> from <code>html form</code>:</p>
  
  <pre><code>formToValues = function (id) {
      var i, values = {}, form = document.getElementById(id);
      //var fields = form.querySelectorAll('input,textarea,select'),
      for (i = 0; i &lt; form.length ;i++) {
          if( form.elements[i].name !== "" ){
              values[form.elements[i].name] = form.elements[i].value;
          }
      }
      return values;
  }
  
  
  ajax('a.php', function(response){
      console.log(response);
  }, formToValues("regForm") );
  </code></pre>
  
  <p>here is also my <code>html form</code>:</p>
  
  <pre><code>&lt;form id="regForm" action="javascript:;" method="post" /&gt;
  &lt;p&gt;
  &lt;label for="name"&gt;Name&lt;/label&gt;
  &lt;input type="text" name="name" value="xhr" /&gt;
  
  &lt;label for="email"&gt;Email:&lt;/label&gt;
  &lt;input type="email" name="email" value="ro@ew.gq" /&gt;
  
  &lt;label for="password"&gt;Password:&lt;/label&gt;
  &lt;input type="password" name="password" value="pass" /&gt;
  
  &lt;input type="button" value="Search" /&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p></p>
  
  <p>now i have a liitle problem reciving data in <code>php</code> script:
  <code>a.php</code>:</p>
  
  <pre><code>&lt;?php
  var_dump(  $GLOBALS );
  $ar= array( "a"=&gt;2,"b"=&gt;3, "c"=&gt;json_decode( $_REQUEST['params'] ));
  echo json_encode($ar);
  ?&gt;
  </code></pre>
  
  <p>seems like php take my data sended from javascrip as string and store it in <code>HTTP_RAW_POST_DATA</code></p>
  
  <p><code>["HTTP_RAW_POST_DATA"]=&gt;
      string(51) "{"name":"xhr","email":"ro@ew.gq","password":"pass"}"</code></p>
  
  <pre><code>    "array(7) {
    ["GLOBALS"]=&gt;
    array(7) {
      ["GLOBALS"]=&gt;
      *RECURSION*
      ["HTTP_RAW_POST_DATA"]=&gt;
      string(51) "{"name":"xhr","email":"ro@ew.gq","password":"pass"}"
      ["_POST"]=&gt;
      array(0) {
      }
      ["_GET"]=&gt;
      array(0) {
      }
      ["_COOKIE"]=&gt;
      array(0) {
      }
      ["_FILES"]=&gt;
      array(0) {
      }
      ["_REQUEST"]=&gt;
      array(0) {
      }
    }
  </code></pre>
  
  <p>now i can get data with  <code>php://input</code> will not be a problem but i am concernet about security and it dos'n sems ok, and it's one more thing to get in consideration : starting with php version 5.6.0. $HTTP_RAW_POST_DATA — Raw POST data is deprecated~ so what should i do? 
  Tkanks</p>