English 中文(简体)
F5 (已提交)
原标题:F5 (refresh) act as submit

我有一个隐蔽的参数,即应穿透一个价值载荷的行为,但必须把纽伦放在外。

The problem is when pressing on the F5 (refresh) button after pressing the submit button because the url already contain &act=save so prssing on F5 actually pass (to cgi) the save value again (and it perform the save action again even I didn t press on the submit button.

The queston is how can I prevent sending the &act=save on pressing the reffresh button?

增 编


增 编 you all but the submit button is a save button - means I wish to leave the user the abbility to perfrom addiitonal save so don t wany to leave the page. From this reason, I don t think that the session may help to distinguish between the second save or the first refresh.

问题回答

这里的核心问题是,在你应当使用POST时,你正在使用GET。 The HTTP specification states :

尤其是,公约确定,教育、青年和体育部及欧洲环保局的方法具有采取除检索以外的行动的重要性。

如果你使用POST,浏览器至少会警告你重新提交表格。

为了避免这种情况,使用。 POST-Redirect-GET patterns

您可以真正防止用户使用F5,或防止该网页重新提交表格,即使使用< POST方法,其形式将使用户能够修改数据。

克服这种情况的两个共同点:

  1. 采用会议变量,将其放在第一种形式上,然后加以核对——如果存在,则意味着已经提交的表格仅仅忽视了它或张贴习俗信息。

  2. 在成功提交文件后,将用户转至不同的网页,这样,点击F5后,新网页将重新上载,并赢得数据翻版。

一种比已经提供的更为复杂的解决办法是,每生成一个带有表格的网页时,就采取行动。 这项象征性行动储存在服务器上,并发送给客户。 当客户提交表格时,它包括象征性行动。 当服务器收到一份表格时,该服务器检查了针对该用户会议所储存的象征性或象征性物体采取的行动。 如果与未到期照相,则允许继续处理表格,并在本届会议上停止处理。

这使得表格无法不止一次提交,而且附带利益是,如果得到适当执行,它有助于减少交叉要求伪造。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签