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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:15:51+00:00 2026-06-08T00:15:51+00:00

Possible Duplicate: Why does this code not increment a counter properly? I have a

  • 0

Possible Duplicate:
Why does this code not increment a counter properly?

I have a problem when it comes to displaying the correct page number.

I have a demo which you can use to see what is happening:

  • Step 1: When you open the app, type in the number 8 in the textbox
    and then submit.
  • 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.
  • 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.

Below is the problem:

  • 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.

  • 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”

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.

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.

Below is the code for how it currently counts the page numbers and how it displays it on top:

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


$sessionMinus =  $_SESSION['sessionCount'];

?>

…

<h1>CREATING QUESTIONS AND ANSWERS: SESSION <?php echo $sessionMinus ?> OF <?php echo $_SESSION['initial_count'] ?></h1>
  • 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-08T00:15:53+00:00Added an answer on June 8, 2026 at 12:15 am

    In create_session2.php, you’ll need to differentiate the question adding and submitting of details. For instance, try using isset($_POST['submitDetails']). This variable will only be set if your user clicked on your submitDetails button to get to the form.

    Example:

    ...
    if (isset($_POST['submitDetails'])) {
        session++;
    }
    ...
    

    This way, you’ll know whether or not to increment your session amount as a result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why does this Random Number Generator not random? I have this test
Possible Duplicate: Why does this Javascript code inside a non-Javascript browser have extra commenting?
Possible Duplicate: or is not valid C++ : why does this code compile ?
Possible Duplicate: Python list append behavior Why does this code: x = [[]]*3 x[0].append('a')
Possible Duplicate: Why does this integer division yield 0? I have a C header
Possible Duplicate: Why does this intentionally incorrect use of strcpy not fail horribly? Below
Possible Duplicate: Reference - What does this symbol mean in PHP? I have a
Possible Duplicate: Invalid read/write sometimes creates segmentation fault and sometimes does not I have
Possible Duplicate: What does jQuery.fn mean? I have some script on a page trying
Possible Duplicate: What does this mean? (function (x,y)){…}){a,b); in JavaScript I have the following

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.