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 9089063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:03:16+00:00 2026-06-16T22:03:16+00:00

Below I am trying to create a feature where if a user is on

  • 0

Below I am trying to create a feature where if a user is on a current page, all the other pages in the array are locked out (cannot be accessed), the other pages cannot be accessed until the user has completed the current page they are on.

Now below is the code which deals with 6 php scripts:

        <script type="text/javascript">

$(function() {
    var link = $("#createLink");

    link.click(function() {
        $.ajax({
           url: "removesession.php",
           async: false,
           type: "POST",
           success: function() {
                window.location.href = link.attr("href");
           }
         });

         //cancels the links true action of navigation
         return false;
    });
);
</script>

    <?php

    $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

    $latestStep = $_SESSION['latestStep'];
    $currentStep = basename(__FILE__); 

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

    if ($currentIdx - $latestIdx > 1 ) {
        ?>
    <div class="boxed">
    <a href="<?= $pages[$currentPages+1] ?>">Continue</a>
    <br/><a href="create_session.php" id="createLink">Create New</a>
    </div>

    <?



    } else {
        // let the user do the step
    }

    ?>

So here is an example of what could happen:

  1. User is on penalty.php page, so the other pages in the array are
    locked out
  2. 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 penalty.php page

    • If user selects Create New link then it should navigate to the create_session.php and perform the jquery/ajax method and navigate to the removesession.php script in the background

Now the code above is in a php script known as steps.php and this is externalized so that it can be accessed using include(steps.php) and this will be included in the 6 php scripts in the array so that those scripts can access those pages.

Now my question is that I need to do one more thing in this code which deals with the if/else statement I have in the code above and including code in the other scripts:

Using return values, return 1 if user can do the step, 0 if they can
not. Then on each page, you’d call this function, and depending on the
return value, either show the page, or show the error

My question is that I don’t quite seem to know how to code what is mentioned in the above quotation. Can somebody show what the if/else statement should look like and what code should be included in one of the php scripts of the 6 in order to be able to call the function in that script?

UPDATE:

steps.php

<?php

function allowed_in($steps){

$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

$latestStep = $_SESSION['latestStep'];
$currentStep = basename(__FILE__); 

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

if ($currentIdx - $latestIdx > 1 ) {

   return 1;

} else {

    return 0;

}

}

?>

create_session.php:

if(allowed_in($steps)){

//all code in the create_session.php

}else{
?>

<div class="boxed">
  <a href="<?= $pages[$currentPages+1] ?>">Continue</a>
<br/>
<a href="create_session.php" id="createLink">Create New</a>
</div>

<?php   

}

?>
  • 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-16T22:03:18+00:00Added an answer on June 16, 2026 at 10:03 pm

    very pseudo code:

    function allowed_in($pased_vars){
    
    //your code
    
    if($foo){
        return 1;
    }else{
        return 0;
    }
    
    }
    

    on included pages

    <?php
    //include file with code
    
    if(allowed_in($vars)){
    //allowed
    }else{
    //not
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create something like a lock and unlock pages feature. The
Im trying to figure out a most basic feature, to create a named route
I am trying to create an array of objects like below as expected by
I am trying to create the below matrix in my vb.net so during processing
I am trying to create a CSS theme switcher button like below. The top
I'm trying to create a custom drop down and using the code below it
I am trying to create an iPhone app as in the fig below: In
I am trying to create an add-in by using the article below http://blogs.microsoft.co.il/blogs/shair/archive/2008/07/28/how-to-create-sql-server-management-studio-addin.aspx I
I'm trying to create a pinterest pin it button. Below is the code: <a
InSymfony (Doctrine) I am trying to create a public function with the code below.

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.