Manish Trivedi
Manish Trivedi

Reputation: 3559

GET an POST data for Mozilla

I am doing my work in PHP. I have 3 pages, A is plain HTML and contains a search field. B is .php and returns results of the search. C is also php and allows user to update some details for the displayed results.

When I'm doing Refresh my B page or Go-Back from C to then 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."

I saw "When i'm using "POST" method then I get this message, if I'm used GET then I don't.

Any buddy Explain me ,why???

Upvotes: 0

Views: 641

Answers (6)

Jared
Jared

Reputation: 3016

When you submit data in the POST method, it sends headers to the page you submit to. When you refresh the page or go back, your browser repeats your POST request and Firefox warns you of this.

Upvotes: -2

Neil
Neil

Reputation: 55402

Firefox should normally allow you to navigate back to your B page from your C page. However if your B page is not in the cache, possibly because it sends a Cache-control: no-store header, then you will get the POSTDATA warning.

On the other hand explicitly reloading page B will always generate a POSTDATA warning.

Upvotes: 0

Nick
Nick

Reputation: 2478

I think the point is that GET requests should be used to get information without changing anything on the server so if you reload the same information there's no issue. POST requests should be used to change data on the server so when you reload the page that may have undesirable effects.

Upvotes: 0

Sarwar Erfan
Sarwar Erfan

Reputation: 18068

Firefox developers added that warning for POST method. It will warn you for POST in case of back/forward also.

This is an added safeguard for users. Because, most shopping carts/banking portals use POST method for checkout/transaction confirmation (actually I have not seen or developed any web app to use get method for this purpose).

So, Firefox (and most other common browsers) warn you in this scenario (when your are sending POST request indirectly, i.e. using back/forward/refresh button). This prevents the user from multiple checkout.

Another reason to add this warning is, sometimes chekout is time consuming. So, when some time is passed after the original submission, some impatient users think that the browser/server has stopped working. So, they tend to press the refresh button. This warning gives them a good hint.

Upvotes: 1

Vadiklk
Vadiklk

Reputation: 3764

A wild guess, POST is not written in the URL, so you need to resend it, while GET, when you click to return to B, the arguments are still in the URL so you dont need to resend.

Mozilla added this message to warn you from sending the information twice. Like in the form of registration, you don't want to register twice.

Upvotes: 2

aiham
aiham

Reputation: 3614

The GET method should be used to obtain information from a web page.

The POST method should be used to send information to a web page.

The reason it asks you to confirm whether or not to send information again is because it's not always the user's intention to repost a form if they press back. One example is at an online store, you would not want to repost a form to purchase a product twice, otherwise you could be billed for the product twice. This is theoretical of course since someone who makes an online store should ensure that an accidental purchase can't happen.

Also, if you use GET, then all information is appended to the URL of the PHP page. This is a potential security issue, especially if the form contents are private. For such forms, you should be using POST.

Upvotes: 3

Related Questions