获取 Mozilla 的 POST 数据
我正在用 PHP 做我的工作。 我有3页, A 是纯 HTML,包含一个搜索字段。 B 是 .php 并返回搜索结果。 C 也是 php,允许用户更新显示结果的一些详细信息。
当我刷新我的 B 页面或从 C 返回到那时时 收到此消息
“要显示此页面,Firefox 必须 发送将重复任何内容的信息 操作(例如搜索或订单 确认)已执行 早些时候。”
我看到“当我使用“POST”方法时,我会收到此消息,如果我使用 GET 那么 我不知道。
有哪位朋友解释一下,为什么???
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???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
应该使用 GET 方法从网页获取信息。
应使用 POST 方法将信息发送到网页。
它要求您确认是否再次发送信息的原因是,如果用户按回键,并不总是打算重新发布表单。一个例子是在一家在线商店,您不希望重新发布表单来两次购买产品,否则您可能会被收取两次该产品的费用。这当然是理论上的,因为创建在线商店的人应该确保不会发生意外购买。
另外,如果您使用 GET,则所有信息都会附加到 PHP 页面的 URL 中。这是一个潜在的安全问题,尤其是在表单内容是私有的情况下。对于此类表单,您应该使用 POST。
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.
一个疯狂的猜测,
URL中没有写POST,所以需要重新发送,而GET,当你点击返回B时,参数仍然在URL中,所以不需要重新发送。
Mozilla 添加此消息是为了警告您不要重复发送该信息。
就像注册的形式一样,你不想注册两次。
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.
Firefox 开发人员为 POST 方法添加了该警告。如果发生后退/前进,它也会警告您进行 POST。
这对用户来说是一个额外的保障。因为,大多数购物车/银行门户使用 POST 方法进行结账/交易确认(实际上我还没有看到或开发任何网络应用程序来使用 get 方法来实现此目的)。
因此,Firefox(以及大多数其他常见浏览器)会在这种情况下向您发出警告(当您间接发送 POST 请求时,即使用后退/前进/刷新按钮)。这可以防止用户多次结帐。
添加此警告的另一个原因是,有时结帐很耗时。因此,当最初提交后经过一段时间后,一些不耐烦的用户会认为浏览器/服务器已经停止工作。因此,他们倾向于按下刷新按钮。这个警告给了他们一个很好的提示。
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.
我认为重点是 GET 请求应该用于获取信息而不更改服务器上的任何内容,因此如果您重新加载相同的信息就没有问题。 POST 请求应该用于更改服务器上的数据,因此当您重新加载页面时可能会产生不良影响。
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.
Firefox 通常应该允许您从 C 页面导航回 B 页面。但是,如果您的 B 页面不在缓存中,可能是因为它发送了 Cache-control: no-store 标头,那么您将收到 POSTDATA 警告。
另一方面,显式重新加载页面 B 将始终生成 POSTDATA 警告。
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.
当您在 POST 方法中提交数据时,它会将标头发送到您提交的页面。当您刷新页面或返回时,您的浏览器会重复您的 POST 请求,并且 Firefox 会对此发出警告。
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.