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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:18:50+00:00 2026-05-26T03:18:50+00:00

I have a PHP script ( script A ) that makes a query to

  • 0

I have a PHP script (script A) that makes a query to the database, stores the result in a session variable and produces a HTML page containing a form that allows the user to post a submission (optionally). Upon submission, the result stored in the session variable is used for processing in another script (script B).

As the HTML page is not unique, the user may open multiple tabs showing different pages generated by script A. Since the session variable can only hold data for the latest generated page, when the user clicks on any of the previous tabs and do a submission, the wrong set of session data will be used.

One way to preventing this from happening is to force the page to automatically reload before submission occurs. Is there any better and secure way to do this short of re-querying the database in script B?

  • 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-05-26T03:18:51+00:00Added an answer on May 26, 2026 at 3:18 am

    Generate a secret token and a hash of it.

    Add the secret token to your $_SESSION.

    Add the hash to the form as a hidden input element.

    On Submission, create the hash from the secret token in $_SESSION.

    Compare it to the submitted hash. If it mismatches, you know that the form is wrong for your session.

    You can extend that, by keying the data with the hash inside your $_SESSION:

    $_SESSION[$hash] = your form data
    

    Then you can even process multiple forms (and multiple form instances) correctly.

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

Sidebar

Related Questions

I have a php script that makes a random token (A-Z, a-z, 0-9): function
I have a PHP script search script that logs every query made in a
i have a database in MySQL who i query from a php script. Now
I currently have a page setup like this: PHP Variable Declarations HTML header, then
I currently have a page setup like this: PHP Variable Declarations HTML header, then
I have a PHP script (index.php) that changes the page shown depending on the
I have php script that creates a temporary watermark image for users that are
I have a PHP script that runs as a CGI program and the HTTP
I have a PHP script that needs to determine if it's been executed via
I have a PHP script that initialises an image gallery. It loops through all

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.