发布表单数据

发布于 2024-10-03 06:29:43 字数 196 浏览 7 评论 0原文

我有一个 HTML 表单,我想发布数据,然后向用户显示一些文本。我听几个人讨论过这个想法:

用户是否应该从[表单页面] -> 转到[表单页面]? [处理表单post页面]-> [显示页面] 还是用户应该直接转到组合的[表单页面] -> [处理表单/显示页面]

我听说过前者更安全,而后者重定向更少。

有哪些答案?

I have an HTML form which I want to post data to then display some text to the user. I've heard several people discuss this idea:

should the user go from [form page] -> [processing form post page] -> [display page] or should the user just go to a combined [form page] -> [processing form / display page]

I've heard arguments the former is more secure while the latter is less redirects.

What are some answers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

余厌 2024-10-10 06:29:43

为了避免缓存问题、重新提交刷新问题和类似问题:使用 POST-REDIRECT-GET 模式。

  1. 浏览器使用表单数据发出 HTTP POST 请求
  2. 服务器处理数据并以重定向响应进行响应
  3. 浏览器发出 HTTP GET 请求(可能包括与查询字符串中提交的数据相关的 id)
  4. 服务器以 200 响应和信息进行响应

To avoid caching issues, resubmission on refresh issues and similar problems: Use the POST-REDIRECT-GET pattern.

  1. Browser makes HTTP POST request with form data
  2. Server processes data and responds with a redirect response
  3. Browser makes HTTP GET request (possibly including an id that is related to the submitted data in the query string)
  4. Server responds with a 200 response and the information
哭了丶谁疼 2024-10-10 06:29:43

根据您提出的问题,您可以只拥有 [form page] -> [要处理和显示的表单页面]。

From what your question asked, you could just have the [form page] -> [form page to process and display].

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文