当前位置: 动力学知识库 > 问答 > 编程问答 >

GET vs. POST (form processing)

问题描述:

I completely understand the differences between the two in terms of form handling, user discretion and privacy of data, but in what situation would anyone rather use GET over POST when sending form results?

Thanks

网友答案:

GET places parameters in the URL itself, allowing everyone to see. While POST would be ideal for logins and security-sensitive data, GET is ideal when you want a dynamic page to be bookmarked.

Take a forum for example. The thread which shows all posts within it is loaded dynamically. There doesn't exist a page for every thread available, meaning parameters must be provided which indicate which thread to load. These parameters are passed using GET so that you can bookmark the page and that exact URL with the parameters provided will be used again to load the page.

网友答案:

W3C HTML 4.01 Recommendation on the appropriate usage of GET and POST:

The "get" method should be used when the form is idempotent (i.e., causes no side-effects). Many database searches have no visible side-effects and make ideal applications for the "get" method.

If the service associated with the processing of a form causes side effects (for example, if the form modifies a database or subscription to a service), the "post" method should be used.

Note: The "get" method restricts form data set values to ASCII characters. Only the "post" method (with enctype="multipart/form-data") is specified to cover the entire [ISO10646] character set.

网友答案:

For instance, to make form data visible in logs.

网友答案:

If i need that user can save a bookmark of next step/page (for whatever reason) i would use GET other than that probably POST.

Both are unsafe and you must escape both.

分享给朋友:
您可能感兴趣的文章:
随机阅读: