title: $_POST and $_SERVER['REQUEST_METHOD'] == 'POST'
body: <p>i am using lot of Ajax in my PHP application, and typically to route the POST request for processing i check for an expected variable and a value and based on that i process the script.</p>
  
  <p>For example if i want to delete or insert something using AJAX my typical PHP file that will process the POST request will be like</p>
  
  <pre><code>//Initialize the class on top of the page that will be dealing with CRUD functions.
  $class = new CRUD();
  //Delete Something
  if(isset($_POST['option']) &amp;&amp; $_POST['option'] == 'delete-something') {
      //Delete logic.
  }
  //Save Something
  if(isset($_POST['option']) &amp;&amp; $_POST['option'] == 'save-something') {
      //Save logic.
  }
  </code></pre>
  
  <p>and so on. i was just wondering if the code <code>if(isset($_POST['option']) &amp;&amp; $_POST['option'] == 'delete-something')</code> will give me protection against unauthorized request. or should i be using <code>$_SERVER['REQUEST_METHOD'] == 'POST'</code> along the condition. is there really any difference between the two? because i saw lots of fellow developers using <code>$_SERVER['REQUEST_METHOD'] == 'POST'</code> along. </p>