it is not navigating user to page they should be on
<p>below I have scenario of what SHOULD happen:</p>

<ul>
<li>User is on <code>create_session.php</code> page, so the other pages in the array are
locked out</li>
<li>If user tries to access another page they are displayed with the div
box shown above:</li>
<li>If user selects Continue link then it should navigate the user to the
page they should be on which was <code>create.php</code> page</li>
</ul>

<p>The problem is that if the user accesses another page and the div box appears, if user click on the <code>Continue</code> link, it does not navigate back to the <code>create_session.php</code> page or in other words the page the user was last on.</p>

<p>The url does not seem to change after clicking on the <code>Continue</code> Link</p>

<p>Why is it not navigating the user to the page they should be on after clicking on <code>Continue</code>?</p>

<p>The script that tries to control which pages are locked out and keeping the page the user is on unlocked is in this script <code>steps.php</code> which is shown below:</p>

<pre><code>&lt;?php

function allowed_in(){

$steps = array('create_session.php', 'QandATable.php', 'individualmarks.php', 'penalty.php', 'penaltymarks', 'complete.php');

// Track $latestStep in either a session variable
// $currentStep will be dependent upon the page you're on

if(isset($_SESSION['latestStep'])){
   $latestStep = $_SESSION['latestStep'];
}
else{
   $latestStep = "";
}
$currentStep = basename(__FILE__); 

$currentIdx = array_search($currentStep, $steps);
$latestIdx = array_search($latestStep, $steps);

if ($currentIdx - $latestIdx &gt; 1 ) {

   return true;

} else {

    return false;

}

}

?&gt;
</code></pre>

<p>Now each script stored in the arrays contains the code <code>include('steps.php')</code> and contains the code below:</p>

<pre><code>        &lt;?php

if (allowed_in()){

//create_session.php code

}else{
?&gt;

&lt;div class="boxed"&gt;
&lt;a href="&lt;?php echo $steps[$latestIdx + 1] ?&gt;"&gt;Continue&lt;/a&gt;
&lt;/div&gt;

&lt;?php   

}

?&gt;
</code></pre>

<p><strong>UPDATE:</strong></p>

<p>When I click on <code>Continue</code> link, in url it displayed two errors which were below:</p>

<blockquote>
  <p>notice: Undefined variable: latestIdx in ... on line 1636</p>
  
  <p>Notice: Undefined variable: steps in ... on line 1636</p>
</blockquote>

<p>Notices are displayed for this line below:</p>

<p><code>&lt;a href="&lt;?php echo $steps[$latestIdx + 1] ?&gt;"&gt;Continue&lt;/a&gt;</code></p>

<p><strong>UPDATE 2:</strong></p>

<p>When I navigate to a page which is locked (in other words when the box which states you have to <code>Continue</code> appears, I am getting undefined <code>$_SESSION</code> variables and I am also getting this error: <code>Undefined variable: steps in steps.php on line 57</code></p>

<p>For the <code>$_SESSION</code> undefined errors, is it because I am placing the $_SESSION variables in the wrong place? And how can I stop the undefined variable of steps in steps.php?</p>

<p>Below is an example <code>QandATable.php</code> order of code looks like:</p>

<pre><code>    &lt;?php

    ini_set('session.gc_maxlifetime',12*60*60);
    ini_set('session.gc_divisor', '1');
    ini_set('session.gc_probability', '1');
    ini_set('session.cookie_lifetime', '0');
    require_once 'init.php'; 
    //12 hours sessions

    session_start();
    include('steps.php'); //exteranlised steps.php

    &lt;head&gt;

    if (isset($_POST['id'])) {

    $_SESSION['id'] = $_POST['id'];

    }


    if(isset($_POST['sessionNum'])){
                //Declare my counter for the first time

                $_SESSION['initial_count'] = $_POST['sessionNum'];
                $_SESSION['sessionNum'] = intval($_POST['sessionNum']);
                $_SESSION['sessionCount'] = 1;

        }

    elseif (isset($_POST['submitDetails']) &amp;&amp; $_SESSION['sessionCount'] &lt; $_SESSION['sessionNum']) {
        $_SESSION['sessionCount']++;
    }

    &lt;/head&gt;

    &lt;body&gt;

    &lt;?php 

//once session is expired, it should log the user out, but at mo this isn't happening
    if ((isset($username)) &amp;&amp; (isset($userid))){ //checks if user is logged in

        if (allowed_in()=== "Allowed"){

    //QandATable.php code:

    }else{

    $page = allowed_in()+1;


    ?&gt;

    &lt;div class="boxed"&gt;
      &lt;a href="&lt;?php echo $steps[$page] ?&gt;"&gt;Continue with Current Assessment&lt;/a&gt;

    &lt;?php   

    }

    }else{ 

    echo "Please Login to Access this Page | &lt;a href='./teacherlogin.php'&gt;Login&lt;/a&gt;"; 
    //show above echo if user is not logged in

    }

    ?&gt;
</code></pre>

<p>Below is the full steps.php:</p>

<pre><code>&lt;?php

$steps = array(1 =&gt;'create_session.php',2 =&gt; 'QandATable.php',3 =&gt; 'individualmarks.php',4 =&gt; 'penalty.php',5 =&gt; 'penaltymarks',6 =&gt; 'complete.php');

function allowed_in($steps){
// Track $latestStep in either a session variable
// $currentStep will be dependent upon the page you're on

if(isset($_SESSION['latestStep'])){
   $latestStep = $_SESSION['latestStep'];
}
else{
   $latestStep = 0;
}
$currentStep = basename(__FILE__); 

$currentIdx = array_search($currentStep, $steps);
$latestIdx = array_search($latestStep, $steps);

if ($currentIdx - $latestIdx == 1 )
    {
       $currentIdx = $_SESSION['latestStep'];
       return 'Allowed';
    }
    return $latestIdx;
}

?&gt;
</code></pre>
