title: PHP: How to prevent data from being saved twice
body: <p>I want to prevent comment from being saved twice, so I write those code, but it won't work as my expectation.
  Anyone helps me? Really appreaciated. THX</p>
  
  <pre><code>if( isset($_SESSION['ADDING']) ) {
      jsAlert("adding now, please wait");
  }
  
  $_SESSION['ADDING'] = 1;
  
  saving_data();
  jsAlert("finish");
  
  unset($_SESSION['ADDING']);
  </code></pre>