title: Process database delete action in the same PHP page with post
body: <p>I'm building PHP application for process employee leave records. In this application the main screen populate database records and action buttons. when user click the action button it take the database id from the table and go through another file to delete that record and then redirect back to the same page. This mechanism implemented using HTML _GET method. that means anyone can see the row ID in the URL feed and if anyone request this url with different row ID, PHP file delete the record since any other security measures not taken place in to prevent that. and also this application not using any kind of session.</p>
  
  <p>this is my href code  for the task I mentioned above.</p>
  
  <pre><code>echo "&lt;a href='rejectone.php?id=$lvid' class='btn btn-danger btn-xs m-r-1em'&gt;Cancal&lt;/a&gt;";
  </code></pre>
  
  <p>and this is my rejectone.php code </p>
  
  <pre><code>&lt;?php
  $lid =$_GET['id'];
  include 'database.php';
  $accval = "Accept";
  try {
     $query = "UPDATE leavesrecords SET leavestatus = 'Reject' WHERE lvid = '$lid'";
      $stmt = $con-&gt;prepare( $query );
      $stmt-&gt;bindParam(1, $id);
      $stmt-&gt;execute();
  }
  
  catch(PDOException $exception){
      die('ERROR: ' . $exception-&gt;getMessage());
  }   
  header( "refresh:0;url=bs.php" );           
  ?&gt;
  </code></pre>
  
  <p>I have two questions</p>
  
  <p>1.) How can I run the rejectone task inside the same PHP file without redirecting to another PHP file</p>
  
  <p>2.) How can I use HTML _POST method instead of get method to transfer data if I still use jejectone.php file</p>
  
  <p>thanks!!</p>