Morthian Posted October 5, 2007 Share Posted October 5, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/71910-problem-with-post-data/ Share on other sites More sharing options...
cmgmyr Posted October 5, 2007 Share Posted October 5, 2007 You could do something like this: form.php <?php if($_POST){ //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 />"; } Quote Link to comment https://forums.phpfreaks.com/topic/71910-problem-with-post-data/#findComment-362244 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.