title: Sending POST data to php using angular 5
body: <p>I'm trying to call a web service from angular 5 to PHP. </p>
  
  <p>I'm using POST method but I have trouble retrieving data in PHP side. </p>
  
  <p>Send data is shown in payload but it's not retrieved in php side.</p>
  
  <p><strong>Angular service.ts</strong></p>
  
  <pre><code>this.URL = "http://localhost/angular/WEBSERVICE_PHP/test.php";
  
  const headers = new Headers();
  headers.append('Content-Type', 'application/json');
  let data = 'visitor_id=55';
  
  return this.http
  .post(this.URL,JSON.stringify(data),{
      headers: headers
  })
  .map( Response =&gt; console.log(Response) );
  </code></pre>
  
  <p><strong>PHP PAGE</strong></p>
  
  <pre><code>header("Access-Control-Allow-Origin: *");
  header("Access-Control-Allow-Credentials: true");
  header("Access-Control-Allow-Methods: POST, GET");
  header('P3P: CP="CAO PSA OUR"'); // Makes IE to support cookies
  header('content-type: text/plain');  
  header("content-type: application/x-www-form-urlencoded");
  header("Access-Control-Allow-Headers: Content-Type, Authorization, X- 
  Requested-With");
  header("Access-Control-Max-Age: 172800");
  
  if(isset($_POST))
  {
      // $post = 'test data';     // This data get sent
      //   return $post;
      echo $post = $_POST['visitor_id'];
      return $post; 
  }
  </code></pre>