title: How to display the correct page number?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11331702/why-does-this-code-not-increment-a-counter-properly">Why does this code not increment a counter properly?</a>  </p>
  </blockquote>
  
  
  
  <p>I have a problem when it comes to displaying the correct page number.</p>
  
  <p>I have a <a href="http://helios.hud.ac.uk/u0867587/Mobile_app/Text4.php" rel="nofollow noreferrer">demo</a> which you can use to see what is happening:</p>
  
  <ul>
  <li>Step 1: When you open the app, type in the number 8 in the textbox
  and then submit.</li>
  <li>Step 2: you will see at the top of the page it states "CREATING
  QUESTIONS AND ANSWERS: SESSION 1 OF 8" This is correct as you are
  currently on the first page out of 8.</li>
  <li>Step 3: Now click on the "Submit Details" button at the bottom, you
  will see that it now states "CREATING QUESTIONS AND ANSWERS: SESSION
  2 OF 8". Again this is fine as that you are now on the second page
  out of 8.</li>
  </ul>
  
  <p>Below is the problem:</p>
  
  <ul>
  <li><p>Step 4: If you click on the "Add Question" button twice, you will see
  2 rows appear below, both rows containing its own image file upload
  form.</p></li>
  <li><p>Step 5: Click on the "Submit Details" button, you will realise that
  you are not on page 3 as it is not stating "CREATING QUESTIONS AND
  ANSWERS: SESSION 3 OF 8", but instead it is stating "CREATING
  QUESTIONS AND ANSWERS: SESSION 5 OF 8"</p></li>
  </ul>
  
  <p>The reason I believe it is doing this is because when you click on the "Submit Details" button, it submits the whole form but also as that there are a couple of image file uploads forms appeanded into a row, it is counting them as well in the submit, so that is why it is stating we are on page 5 and not page 3.</p>
  
  <p>So my question is that what do I need to change in my code in order to be able to display the correct page number? Everytime the user clicks on the "Submit Details" button, it should count the page number by only +1 each time.</p>
  
  <p>Below is the code for how it currently counts the page numbers and how it displays it on top:</p>
  
  <pre><code>            &lt;?php
  
  session_start();
  
  
  if(isset($_POST['sessionNum'])){
              //Declare my counter for the first time
  
              $_SESSION['initial_count'] = $_POST['sessionNum'];
              $_SESSION['sessionNum'] = intval($_POST['sessionNum']);
              $_SESSION['sessionCount'] = 1;
  
      }
  
  else if ($_SESSION['sessionCount'] &lt; $_SESSION['sessionNum']) {
      $_SESSION['sessionCount']++;
  }
  
  
  $sessionMinus =  $_SESSION['sessionCount'];
  
  ?&gt;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>&lt;h1&gt;CREATING QUESTIONS AND ANSWERS: SESSION &lt;?php echo $sessionMinus ?&gt; OF &lt;?php echo $_SESSION['initial_count'] ?&gt;&lt;/h1&gt;
  </code></pre>