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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:01:45+00:00 2026-05-28T02:01:45+00:00

I detect a form submit on an ‘addrecord’ button being pressed, and then I

  • 0

I detect a form submit on an ‘addrecord’ button being pressed, and then I reset the value of that ‘addrecord’ button in the $_POST array:

if(array_key_exists('addrecord', $_POST))
{   
    var_dump($_POST);

    if($_POST['addrecord'] == "ADD RECORD")
    {
        $_POST['addrecord'] = "Handled already.";  // prevents a 'reload' 
                                                   // from adding the same record again
       // now do the 'addrecord' -- just once -- to the database
    }
    else
    {
       // yay -- we avoided adding the same record on a browser reload 
    }
 }

And here is the problem — when I click the ‘reload’ button in Firefox 8, the var_dump above shows me —
the post array’s ‘addrecord’ value is NOT the string “Handled already.” — it is still “ADD RECORD”.

  • when the user clicked the ‘addrecord’ button, the server gets a POST array and the addrecord button has the value
    “ADD RECORD” — here is the add record button on my form:

         <input type="submit" name="addrecord" value="ADD RECORD" />
    
  • and then on the server side, I see the value of ‘addrecord’ is “ADD RECORD” and I change the POST array’s ‘addrecord’ element
    from “ADD RECORD” to “Handled already.”

  • and then the server sends a new page to the browser that says “Record Added!”

So it seems like the POST array’s value of the ‘addrecord’ element is no longer “ADD RECORD”, because I changed it to “Handled already”. If the user does not press the ‘add record’ button on the form again but only does a page reload — how then can the browser re-set the POST array from “Handled already” — to “ADD RECORD”? Why, when the server receives the page reload, does the POST array’s ‘addrecord’ element lose the value I set previously, “Handled already.” ?

Because when I click ‘reload’ on the browser, var_dump tells me — that is exactly what has happened: the POST array’s ‘addrecord’ value is now right back to “ADD RECORD” — even though the user did NOT click on the form’s add record button.

Why? Does the browser somehow have a cached copy of the values used to fill the POST array on the server, so that even if you change the POST array in php on the server, that the browser will re-submit a cached copy of all the old form values?

  • 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-28T02:01:46+00:00Added an answer on May 28, 2026 at 2:01 am

    Yes, the browser remembers the POST data, and that cached information is unaffected by anything you write in your form-processing PHP code. If the user hits reload, the same POST data will be sent again.

    One alternate approach to keep the reload from inserting the same data again is to include a “submission identifier” column in your database column. When you display the form for the user to fill out, include a hidden form field with a unique identifier — see PHP’s uniqid() or microtime() functions. Then you can either:

    a) query your database before sending the INSERT command, to see if a form with that submission ID has already been submitted, or

    b) simply add a UNIQUE index to that new column in your database table, so that duplicate records can’t be created.

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

Sidebar

Related Questions

Lets say there is a form with a submit button. I found out that
i have a submit form that consist of 1 group radio button. <div id=defectclass>
After a user submits a form, how do you detect that the form has
I'm using .submit() to detect when a form is submitted, but instead of performing
I have an html form which includes a textarea box and a submit button
How do you detect which form input has focus using JavaScript or jQuery? From
I have a requirement to create a windows form control which has to detect
In MDI application which event can the child Form class use to detect when
I'm working on a jQuery function that forwards form data to page without interfering
How can I detect whether a form was submitted via an AJAX post or

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.