Page 1 of 1

Browser sends Post data again

Posted: Mon Aug 22, 2005 9:41 am
by OregonGhost
In my web app I use several forms that send data using post, which is then inserted into a database. In most instances the data is unique and cannot be inserted into the database twice, but I have one table where datasets don't need to be unique. I could of course add an auto_increment index field, and then anytime when the form is displayed, find the highest stored index (the next auto_increment would supply) and put it into the form data. Then, when the data is to be stored, I could compare the two indices and duplicate entries could be denied at this stage.
However, I'd like to solve this another way.
The form forwards to a php file (the same, actually) which stores the data into the database and then sends a Location-Header to reload the page without sending the post data again. This works as expected on Internet Explorer, but Mozilla Firefox asks the user if the post data should be sent again, and if he clicks OK, the data is stored again into the database.

My actual question now is the following:
Can this be done using the second approach (and what do I have to do different to make it run on Mozilla Firefox, if so), or do I need to do use the first method?
Alternative ways are ok, too :)

Thanks in Advance,
OregonGhost

Posted: Mon Aug 22, 2005 9:47 am
by feyd
both methods are viable, and should be pursued I think. To get the second to work with Firefox, you need to output a redirection page. Firefox will accept that as the destination for the submission and not the redirected location. The redirection page should use a meta-refresh tag, or Javascript to perform the redirection instead of the header() one.