<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Chan Chen Coding...

    GET Method versus POST Method

    Refer to:http://www.programmerinterview.com/index.php/general-miscellaneous/html-get-vs-post/
    Refer to:http://www.cs.tut.fi/~jkorpela/forms/methods.html

    In HTML forms, what’s the difference between using the GET method versus POST?

     

    Pretty much anyone who’s been on the web has undoubtedly used an HTML form at some point. Whenever you enter in any personal information on a site and hit a submit button, you are putting that information into an HTML form.

    A form is used to pass information from a web browser to a web server. For example, if logging into an email provider like yahoo mail or gmail, you would input your username and password inside an html form. Then, by clicking the "sign in" button you’re submitting your username and password (inside a form) from your web browser to one of Yahoo’s or Google’s webservers.

    There are two different ways that a form can be submitted from your browser to the webserver. In HTML, this is how one would define the opening form tags for both submission methods: <form method="GET"> and <form method="POST">.

    When a form is submitted, an HTTP request that passes the data to the web server is generated. Think of HTTP as the language that your web browser uses to ‘speak’ with web servers. The type of HTTP request generated depends on the method used to submit the form (either a GET or a POST).


    If a "GET" request is used, the form parameters are encoded in the URL in what is called a query string. The form parameters can be anything, and in the example we gave earlier they would be the username and password for your email provider. Here’s an example of the query string that would be generated if we were to use a "GET" request:

    www.someemailprovider.com/?login=joe@email.com&password=xxyz 

    In the GET request above, you can see that the form parameters (login and password) are attached to the end of the URL itself. Note that defining a login form to use the GET request method – as we did in this example – is a very bad idea. This is because people logging in will see their passwords being displayed in the url and may be led to think that your site is not secure. One should almost always use a POST form whenever passwords are involved, for other reasons that are explained below.

    A POST request, unlike a GET request, passes the form parameters in the body of the HTTP request, not in the URL. This happens behind the scenes, in what can be thought of as an HTTP ‘dialogue’ between your web browser and a webserver.

    However, the main difference between GET and POST requests is that GET requests are meant to be (although not always are, because this depends on the programmer of the form) idempotent. What idempotent means is that one GET request for a particular URL, including the form parameters, is the same as 2 or more requests for that URL. This is because the response page is always the same. So, your web browser can usually cache the response pages for GET requests, because they should not change. POST requests, however, are not meant to be idempotent. This means that they cannot be cached, and the server is recontacted each time the page is displayed. POST requests are most suitable for queries where the response page will change over time – like a shopping cart.

    With all that said, idempotence is mostly ignored in the real world. Keep in mind that no one is enforcing idempotence – its more like a best practice guide.

    The main thing to keep in mind as a programmer is that defining your form to use the GET method does not protect against causing changes. You could use a GET request to do pretty much the same thing as a POST query. It’s just that browsers are generally coded to expect that POST requests will be used for things that will cause changes – like placing an order, or writing to a database, etc . GET requests should be used for pure queries that don’t affect anything on the serverSo, one should always remember not to use GET requests for any action that would cause a change on the server – like ordering a big screen tv.



    -----------------------------------------------------
    Silence, the way to avoid many problems;
    Smile, the way to solve many problems;

    posted on 2012-02-24 23:21 Chan Chen 閱讀(243) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 成人免费的性色视频| 最近2019免费中文字幕6| 香蕉视频在线观看免费国产婷婷| 麻豆亚洲AV永久无码精品久久| 免费福利电影在线观看| 日本亚洲欧洲免费天堂午夜看片女人员| 一个人看的www免费高清| 亚洲综合亚洲综合网成人| 中文字幕在线免费看| 亚洲国产精品成人精品无码区在线| A片在线免费观看| 亚洲无线电影官网| 国内精品免费麻豆网站91麻豆| 亚洲videosbestsex日本| 国产精彩免费视频| 激情亚洲一区国产精品| 在线中文高清资源免费观看| 99亚洲男女激情在线观看| 亚洲黄黄黄网站在线观看| 最近中文字幕大全免费版在线| 久久精品九九亚洲精品| 免费无码肉片在线观看| 黄色毛片免费在线观看| 日本红怡院亚洲红怡院最新| 日本免费一区二区在线观看| 亚洲精品第一国产综合亚AV| 亚洲成A人片在线观看中文| 成人性生交大片免费看好| 77777午夜亚洲| 亚洲国产小视频精品久久久三级| 丁香花在线视频观看免费| 国产精品亚洲午夜一区二区三区 | 亚洲精品中文字幕乱码| 免费无码又爽又刺激聊天APP| 免费人成大片在线观看播放电影| 久久91亚洲精品中文字幕| 成人毛片免费观看视频在线| 农村寡妇一级毛片免费看视频| 亚洲国产精品VA在线看黑人| 女性自慰aⅴ片高清免费| 久久成人永久免费播放|