title: PHP & Javascript : How to protect web hacker for post and get method?
body: <p>Here is my sample.html file located in <a href="http://www.aaa.com/sample.html" rel="nofollow">http://www.aaa.com/sample.html</a></p>
  
  <pre><code>&lt;html&gt;
  &lt;script&gt;
     $(document).ready(function(){
       $.post('http://www.aaa.com/api/_file.php?act=add', {val : '1234'});
     });
  &lt;/script&gt;
  &lt;body&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and this is my PHP file that recieve request from sample.html file</p>
  
  <pre><code>&lt;?php
    switch($_GET['act']){
      case 'add' :
      doFunction();
      break;
    }
  
    function doFunction(){
      echo $_POST['val'];
    }
  
  ?&gt;
  </code></pre>
  
  <p>if I have another html page like hack.html that located on another website, example <a href="http://www.bbb.com/hack.html" rel="nofollow">http://www.bbb.com/hack.html</a></p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
    &lt;a href="http://www.aaa.com/api.php_file.php?act=add"&gt;Hack them!!!&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Can I use bbb.com website to access data in aaa.com by cliking some link? If yes, how do I protect it?</p>
  
  <p>Any idea? or better way?</p>
  
  <p>Reguard. (^^)</p>