title: Higher / lower game
body: <p>I'm trying to make a higher / lower number game. So basically you get one number and the start and then you click a button - higher or lower. So if you click higher and the next number is higher you win otherwise you lose , same goes for lower.The problem comes when I click some of the buttons it gives a new number. So how can I prevent this? Here's my code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt; Gamble &lt;/title&gt;
      &lt;meta charset="utf-8"&gt; 
      &lt;link rel="stylesheet" href="style.css" type="text/css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;?php
  
  include('config.php');
  if(!$_SESSION['username']) {
      header("Location: index.php");
  }
  
  Menu();
  isOnline();
  
  $number = rand(0, 100);
  echo $number;
  
  
  if(isset($_POST['higher']) || isset($_POST['lower'])) {
      $num = $number;
      $newNumber = rand(0, 100);
      if($_POST['higher']) {
          if($newNumber &gt; $num) {
              echo 'You win!&lt;br&gt;'.$newNumber;
          }
      } 
  }
  
  ?&gt;
      &lt;form method="POST"&gt;
          &lt;input type="Submit" name="higher" value="Higher"&gt;
          &lt;input type="Submit" name="lower" value="Lower"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>*Note: I know the lower button does not work , I just want to make it for higher 'cause it will work on the same way with lower..</p>
  
  <p>EDIT:
  Working version:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt; Gamble &lt;/title&gt;
      &lt;meta charset="utf-8"&gt; 
      &lt;link rel="stylesheet" href="style.css" type="text/css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;?php
  
      include('config.php');
      if(!$_SESSION['username']) {
          header("Location: index.php");
      }
  
      Menu();
      isOnline();
  
      $num1 = rand(1, 100);
  
      if(isset($_POST)) {
          if($_POST['higher']) {
              $num2 = rand(1, 100);
              $oldNum = intval($_POST['num1']);
                  if($num2 &gt; $oldNum) {
                      echo "You win! Your number:".$oldNum." , and the new number is: ".$num2;
                  }
          }
      }
  
      ?&gt;
      &lt;form method="POST"&gt;
          &lt;input type="Hidden" value="&lt;?= $num1 ?&gt;" name="num1"&gt;&lt;?= $num1 ?&gt;&lt;br&gt;
          &lt;input type="Submit" name="higher" value="Higher"&gt;
          &lt;input type="Submit" name="lower" value="Lower"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>