Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9105373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:05:36+00:00 2026-06-17T02:05:36+00:00

below I have scenario of what SHOULD happen: User is on create_session.php page, so

  • 0

below I have scenario of what SHOULD happen:

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

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

The url does not seem to change after clicking on the Continue Link

Why is it not navigating the user to the page they should be on after clicking on Continue?

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

<?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 > 1 ) {

   return true;

} else {

    return false;

}

}

?>

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

        <?php

if (allowed_in()){

//create_session.php code

}else{
?>

<div class="boxed">
<a href="<?php echo $steps[$latestIdx + 1] ?>">Continue</a>
</div>

<?php   

}

?>

UPDATE:

When I click on Continue link, in url it displayed two errors which were below:

notice: Undefined variable: latestIdx in … on line 1636

Notice: Undefined variable: steps in … on line 1636

Notices are displayed for this line below:

<a href="<?php echo $steps[$latestIdx + 1] ?>">Continue</a>

UPDATE 2:

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

For the $_SESSION 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?

Below is an example QandATable.php order of code looks like:

    <?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

    <head>

    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']) && $_SESSION['sessionCount'] < $_SESSION['sessionNum']) {
        $_SESSION['sessionCount']++;
    }

    </head>

    <body>

    <?php 

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

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

    //QandATable.php code:

    }else{

    $page = allowed_in()+1;


    ?>

    <div class="boxed">
      <a href="<?php echo $steps[$page] ?>">Continue with Current Assessment</a>

    <?php   

    }

    }else{ 

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

    }

    ?>

Below is the full steps.php:

<?php

$steps = array(1 =>'create_session.php',2 => 'QandATable.php',3 => 'individualmarks.php',4 => 'penalty.php',5 => 'penaltymarks',6 => '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;
}

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:05:37+00:00Added an answer on June 17, 2026 at 2:05 am

    This:

    if ($currentIdx - $latestIdx > 1 ) {
    
       return 1;
    
    } else {
    
        return 0;
    
    }
    

    I think Should be this:

    if ($currentIdx - $latestIdx >= 1 )
     {
        return true;
     } 
    return false;
    

    and not sure were this is coming from:

    $pages[$currentPages+1]
    

    Your steps array will need to be declared outside of the function as well
    You have to return $latestIdx if yo plan to use it in the url. I am not sure if you are trying to go back or forward?

    Still not sure if i understand exactly what you want but this should be a start:

     $steps = array(1 =>'create_session.php',2 => 'QandATable.php',3 => 'individualmarks.php',4 => 'penalty.php',5 => 'penaltymarks',6 => 'complete.php');
    function allowed_in($steps)
        {
            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;
    }
    

    and Page

        if (allowed_in()=== "Allowed")
        {
            //create_session.php code
        }
        else
            {
    $page = allowed_in()+1;
    ?>
    
    <div class="boxed">
    <a href="<?php echo $steps[$page] ?>">Continue</a>
    </div>
    
    <?php   
    
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a particular scenario below. The code below should print 'say()' function of
I have a scenario like the below.. <h:selectOneRadio id=someId value=#{myBean.type} required=true> <f:ajax event=valueChange execute=@form
Hey all. Here is the scenario. I have the below code, and I'm needing
In the scenario below, I have a boolean value. Depending on the result, I
My scenario is as shown in the figure below. I have a database which
I have a search page with the following scenarios listed below. I was told
I am struggling with the configuration for the scenario below. I have a custom
My scenario is as below: I have a central database. I have an application
I have a scenario in which I want user to be able to start
I am just starting out with unit testing and have a scenario I'm not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.