title: Prevent other users from calling php file
body: <p>Here I have a PHP code:</p>
  
  <p><strong>UPDATE:</strong>  </p>
  
  <pre><code>&lt;?php
    $pdo=new PDO("mysql:dbname=gmaestro_agro;host=localhost","gmaestro_agro","pass");
    $statement=$pdo-&gt;prepare("SELECT * FROM stat");
    $statement-&gt;execute();
    $results=$statement-&gt;fetchAll(PDO::FETCH_ASSOC);
    $json=json_encode($results);
    echo $json;
  ?&gt;
  </code></pre>
  
  <p>I call this code with Ajax to get data from MySql database, but when some go on domain <code>http://mywebsite.com/get_json.php</code> this code give anyone information of my database. How I can prevent other users from calling this, so only with my JS Ajax code can call it?</p>