title: Combining AJAX JSON to PHP/MySQL? php://input?
body: <p>Both the AJAX/PHP CODE works if tested individually, The AJAX sends the data to an API,
  The PHP Sends the JSON info from a JSON file</p>
  
  <p>What I want is the AJAX to send the JSON data to the PHP which will then be added to the database</p>
  
  <p><em>script.js</em> </p>
  
  <pre><code>$.ajax({
        type: 'POST',
        url: 'http://rest.learncode.academy/api/userabc/friends', //LINK OF THE PHP HERE?
        data: {name: 'Person3', age: 67},
        success: function(data) {
          alert("Friend added!"+ data);
        }
  });
  </code></pre>
  
  <p><em>file.php</em></p>
  
  <pre><code>// Create connection
  $con = new mysqli($servername, $username, $password, $dbname);
  
  //read the json file contents
  $jsondata = file_get_contents('json.json'); // php://input?
  
  //convert json object to php associative array
  $data = json_decode($jsondata, true);
  
  //get the employee details
  $id = $data['id'];
  $name = $data['name'];
  $email = $data['email'];
  //insert into mysql table
  
  $sql = "INSERT INTO users(id, name, email) VALUES('$id', '$name', '$email')";
  $con-&gt;query($sql);
  </code></pre>
  
  <p>I tried inserting the <code>url:  http://localhost/WEP/JQUERYAJAX/mysl/php.php</code> 
  to <em>script.js</em>
  AND <code>php://input</code> to the <em>file.php</em> but didnt work? What can be the solution?</p>