-2

Perhaps you didn't understand what I meant.Let me explain suppose you have a code like this

   if(isset($_POST["submit"])){
    echo "it's ok";
    }

If you execute this code you get the message then after hitting the F5 button the message doesnt disappear.However if you press enter in address bar then the message disappears

I am really confused about it

  • This question almost reads like a comment about *another* question? Please make a question in SO complete in and of itself, so readers have a hope of understanding your issue. – Chris Cousins Aug 24 '18 at 21:53
  • 3
    Hitting enter in the address bar makes a GET request. A form submit makes a POST request. Hitting F5 duplicates the last request. So if you submit a form, you make a POST and see the message. If you then hit F5, you make a POST and see the message. If you then hit enter from the address bar, you make a GET and don't see the message. – Alex Howansky Aug 24 '18 at 21:54
  • Related: https://stackoverflow.com/questions/6320113/how-to-prevent-form-resubmission-when-page-is-refreshed-f5-ctrlr?noredirect=1&lq=1 – user2864740 Aug 24 '18 at 22:58

1 Answers1

2

F5 / Ctrl+R etc. refresh the page. The browser resubmits the same data (aka the POST data) using the same method as the last request. (This is why browsers sometimes display a popup saying the request will be re-submitted.)

If you press enter in the url you are performing a "hard" reload which does not re-submit the POST data -- it simply loads the page/HTML via a normal GET request. So pressing enter is equivalent to navigating to the page in a new tab or window.

user2864740
  • 60,010
  • 15
  • 145
  • 220
Brad
  • 96
  • 7