Jump to content

Problem with POST data


Recommended Posts

I have a script that will upload a file and store its information in a database based on POST data. The script will set a variable to either a success message or an error message, depending on whether the upload was successful or not. The message variable will then be outputted to the user.


The problem here is that if a user successfully uploads a file and then clicks back or refresh in the browser, the "You are trying to view a page that contains POSTDATA" dialog will appear. If the user simply clicks OK on this dialog, the file will be re-uploaded and a duplicate of the submission's record will be created.


The only way I know to avoid this dialog is by using the header() function to clear the POST data. However, if I use this function, not only will the POST data be cleared, but the variable containing the success message will also be cleared, and there will be no confirmation to the user that their submission was uploaded successfully.


How can I solve this problem?

Link to comment
Share on other sites

You could do something like this:



//do what you need with POST here
header("location: form.php?alert=1");

if($_GET['alert'] == 1){
echo "Everything has been uploaded! Please upload some more!<br /><br />";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.