shortysbest Posted May 10, 2010 Share Posted May 10, 2010 I have a comment page that people can add a comment to the page on my website. If you submit a comment and then refresh the page i get this message: "to display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier." If you click resend it posts the same comment again, obviously dont want that. How can i reset the $_POST or whatever so it doesnt do this? Quote Link to comment https://forums.phpfreaks.com/topic/201262-php-comment-page-on-refresh-asks-to-send-data-again-dont-want-_post/ Share on other sites More sharing options...
Adam Posted May 10, 2010 Share Posted May 10, 2010 Once you have successfully added the comment to your database (or however you store them), redirect the user using the header function. Quote Link to comment https://forums.phpfreaks.com/topic/201262-php-comment-page-on-refresh-asks-to-send-data-again-dont-want-_post/#findComment-1055842 Share on other sites More sharing options...
Muddy_Funster Posted May 10, 2010 Share Posted May 10, 2010 You could do it by including a hidden field in your form, <input type="hidden" name="control" value="true" /> Then... On your page that you want to be able to refresh, include <?php //any headers or session_start() statements that you have go here. if(isset($_POST['control'])){ //The Rest Of Your Current Page Code Goes Here unset($_POST['control]); } else{ //only the part of your code that displays the page info, not the part that processes the form gets repeated in here } ?> And see how that goes. Quote Link to comment https://forums.phpfreaks.com/topic/201262-php-comment-page-on-refresh-asks-to-send-data-again-dont-want-_post/#findComment-1055845 Share on other sites More sharing options...
ignace Posted May 10, 2010 Share Posted May 10, 2010 if (!empty($_POST)) { //process if ($insertSuccess) { header('Location: ' . $_SERVER['SCRIPT_NAME']); exit(0); } } After the user submits the form you process it, and you redirect them to the same page. If you now refresh the page FF does not asks you. Edit: MrAdam beat me to it. Quote Link to comment https://forums.phpfreaks.com/topic/201262-php-comment-page-on-refresh-asks-to-send-data-again-dont-want-_post/#findComment-1055848 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.