title: Destroy most sessions
body: <p>I'm trying to make a simple battle script for my game, but after the battle and all, I don't want the player to be able to click refresh and fight the monster again.. or be able to hit submit over and over to keep getting the rewards for winning.. so what would I need to do so after the person hit's the attack button and the battle shows the results, to make it so this can't happen? if I try to session_destroy() that logs the player out aswell as fixing the problem :/</p>
  
  <p>Here's my code any help?</p>
  
  <pre><code>   if(isset($_POST['Submit']))
      {
  
       $player=$_SESSION['username'];
       $playerstats1="SELECT * from users where username='$player'";
       $playerstats2=mysql_query($playerstats1) or die ("Could not find player");
       $playerstats3=mysql_fetch_array($playerstats2);
  
       $pokemonstat1="SELECT * from user_pokemon where belongsto='$player' AND slot='1'";
       $pokemonstat2=mysql_query($pokemonstat1) or die ("Could not find pokemon");
       while($row = mysql_fetch_array($pokemonstat2)){
  
       $yourmonster="SELECT * from pokemon where name='".$row['pokemon']."'";
       $yourmonster2=mysql_query($yourmonster) or die ("Cannot select battle the pokemon");
       $yourmonster3=mysql_fetch_array($yourmonster2);
  
  
       $monstername=$_SESSION['pokemon'];
       $monstername=strip_tags($monstername);
       $selmonster="SELECT * from pokemon where name='$monstername'";
       $selmonster2=mysql_query($selmonster) or die ("Cannot select battle the pokemon");
       $selmonster3=mysql_fetch_array($selmonster2);
  
             $totalskill=$yourmonster3[att] * $row['level'] + $selmonster3[att] * 5;
             $randomnumber=rand(1,$totalskill);
             if($randomnumber&lt;=$yourmonster3[att] * $row['level'])
             {
               echo "&lt;center&gt;";  
               echo "you have won!";
               echo "&lt;/center&gt;";
  
             } else {
                 echo "&lt;center&gt;";
                 echo "you have lost!";
                 echo "&lt;/center&gt;";
             }
           }
      }
  </code></pre>
  
  <p>Updated again.</p>
  
  <pre><code>   $battle_id = md5(uniqid(rand(), true));
      echo $battle_id;
      // $battle_id would be something like 9a8ab59df7079208843086e9b49a7862
  
      // initialise the battle log
      if(!isset($_SESSION['battle_log']) || !is_array($_SESSION['battle_log']))
      {
          $_SESSION['battle_log'] = array();
      }
  
     // Check if the battle hasn't been played
     if(!in_array($battle_id, $_SESSION['battle_log']))
     {
         // add played battle to the log
  
         // ... your battle code goes here
  
  
  
      if(isset($_POST['Submit']))
      {
  
       $player=$_SESSION['username'];
       $playerstats1="SELECT * from users where username='$player'";
       $playerstats2=mysql_query($playerstats1) or die ("Could not find player");
       $playerstats3=mysql_fetch_array($playerstats2);
  
       $pokemonstat1="SELECT * from user_pokemon where belongsto='$player' AND slot='1'";
       $pokemonstat2=mysql_query($pokemonstat1) or die ("Could not find pokemon");
       while($row = mysql_fetch_array($pokemonstat2)){
  
  
  
  
  
       $yourmonster="SELECT * from pokemon where name='".$row['pokemon']."'";
       $yourmonster2=mysql_query($yourmonster) or die ("Cannot select battle the pokemon");
       $yourmonster3=mysql_fetch_array($yourmonster2);
  
  
       $monstername=$_SESSION['pokemon'];
       $monstername=strip_tags($monstername);
       $selmonster="SELECT * from pokemon where name='$monstername'";
       $selmonster2=mysql_query($selmonster) or die ("Cannot select battle the pokemon");
       $selmonster3=mysql_fetch_array($selmonster2);
  
             $totalskill=$yourmonster3[att] * $row['level'] + $selmonster3[att] * 5;
             $randomnumber=rand(1,$totalskill);
             if($randomnumber&lt;=$yourmonster3[att] * $row['level'])
             {
               echo "&lt;center&gt;";  
               echo "you have won!";
               echo "&lt;/center&gt;";
  
             } else {
                 echo "&lt;center&gt;";
                 echo "you have lost!";
                 echo "&lt;/center&gt;";
             }
           }
      }
            $_SESSION['battle_log'][] = $battle_id;
     }else {
  
        echo "Don't try to cheat...";
     }
  </code></pre>