I have a problem when it comes to displaying the correct number in my heading. When a user submits a page and navigates to this current page, I want the heading below to appear:
CREATING QUESTIONS AND ANSWERS: SESSION (AAA) 1 OF 3
As you can see it above it starts with the number 1 as the user is creating their first session. The problem I am getting is that it never displays number 1, it just keeps displaying this below:
CREATING QUESTIONS AND ANSWERS: SESSION (AAA) 3 OF 3
It keeps displaying the number 3 which is incorrect as if the user enters the current page for the first time then obviousl they don't start with session 3, they start with session 1, then 2 then 3.
So my question is how do I get "SESSION 1" to be displayed when the useer enters the page for the first time?
Below is the current code I have:
if(isset($_POST['sessionNum'])){
//Declare my counter for the first time
$_SESSION['initial_count'] = $_POST['sessionNum'];
$_SESSION['sessionNum'] = $_POST['sessionNum'];
}
if (!isset($_SESSION['sessionCount'])) {
$_SESSION['sessionCount'] = 1;
}
else if ($_SESSION['sessionCount'] < $_SESSION['sessionNum']) {
++$_SESSION['sessionCount'];
}
$sessionMinus = $_SESSION['sessionCount'];
...
<h1>CREATING QUESTIONS AND ANSWERS: SESSION (<?php echo $_SESSION['id'] ?>) <?php echo $sessionMinus ?> OF <?php echo $_SESSION['initial_count'] ?></h1>