title: Angular 4 POST to php my sql not working
body: <p>I Am trying to make a simple login check , using angular 4 , php my sql .
  Now i am able to send the details to the php , but i am not able to receive the status after it , i have no idea why.</p>
  
  <p>Simply, i want to check if the username and password are correct, then return some json , else , return false result. </p>
  
  <p>Help please.</p>
  
  <p>Angular : </p>
  
  <pre><code>import { Injectable } from '@angular/core';  
  import { Http,  Response ,RequestOptions,Headers} from '@angular/http';
  import { Observable } from 'rxjs/Observable';
  import 'rxjs/add/operator/map'
  
  @Injectable()
  export class appService {  
  
      postResponse:any ;
      status;
      constructor(private http:Http) { }
  
     insertData() {
      let headers = new Headers({ 'Content-Type': 'application/json' });
      let options = new RequestOptions({ headers: headers });
      return this.http.post('http://localhost:80/angularsql/sql.php',JSON.stringify({firstName:'Joe',lastName:'Smith333'}),{headers:headers})
      .map((res: Response) =&gt; res.json())
      .subscribe((res:'') =&gt; this.postResponse = res);
     }
  }
  </code></pre>
  
  <p>PHP</p>
  
  <pre><code>&lt;?php 
  header("Access-Control-Allow-Origin: *");
  header("Access-Control-Allow-Methods: PUT, GET, POST");
  header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
  $data = json_decode( file_get_contents('php://input'),true );
    $fname =  $data['firstName'];
    $lname =  $data['lastName'];
  
  $con = new mysqli('localhost','root','','angular');
  if($fname=='anan' &amp;&amp; $lname=='kassis') {
  $sql = "insert into users_tbl(firstName,lastName) values('".$fname."','".$lname."')";
  $result = $con-&gt;query($sql);
      $data = [ "status" =&gt; "CORRECT" ];
  echo json_encode($data);
  }
  else {
      $data = [ "status" =&gt; "wrong details inserted" ];
  echo json_encode($data);
  }
  //echo $result;
  </code></pre>
  
  <p>?></p>