i have create a form (so it’s PHP and HTML hybrid-code). it has ability to send ‘$_POST’. And when i click it, it work perfectly on sending and displaying input.
But there’s something happening when i click Ctrl+R in firefox for represhing the page. I got this confim dialog : “To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier“
my question
- what is it, (this confirm dialog ?)
- what i have to do on my code so it able to suppress this dialog ?
You probably have created an HTML page that contains a
<form>. The form is used to send data to the HTTP server (that is, the webserver that hosts your site).The HTTP protocol defines different request types used to send data to the server and to retrieve data from the server. The most used are
GETandPOST. You must learn about all this if you want to be anything more than a very bad PHP programmer, which is unfortunately (or fortunately, if you are on the hacker side) very common.Your problem is that Firefox has arrived on the page you are talking about after sending a POST request. If you reload the page, it has to send the same data again in the form of a POST. Due to the conventions on what a POST request should be used for (usually to modify data on a database), the browser asks the user if he is sure about what he wants to do.
There are mainly two options to circumvent this:
To use the first method, you could simply add a
method="get"parameter to your form tag:To use the second method, you simply redirect the user after the POST request, using something like
The most used pattern is the POST-Redirect, that is, the second method I told you about. There are many security implications on using GET to change data on a database (if you are interested on that, and you should be, as every PHP programmer should, read about XSRF).