[Webinar] Streamline your web hosting managementRegister Today



Posted on 2000-04-18
Medium Priority
Last Modified: 2013-12-25
What is the difference between Post and Get?
Question by:bea_pr
  • 2
  • 2

Expert Comment

ID: 2729282
Hi there,

The POST method is used whenever the name and values of form elements submitted are not to be shown in the URL but the information goes in the header whereas in the GET method u can clearly see the entire list of form elements(name-value pairs) appearing along with the URL.

Hope this clarifies ur doubt.

LVL 16

Accepted Solution

maneshr earned 40 total points
ID: 2731450
Here is some info on your Question.

CGI scripts are called in two main ways, referred to as methods .
The HTTP GET method is used in document retrievals where an identical request will produce an identical result, such as a
dictionary lookup. A GET stores form data in the URL. This means it can be conveniently bookmarked for canned requests,
but has limitations on the total size of the data requested. The HTTP POST method sends form data separate from the request.
It has no such size limitations, but cannot be bookmarked. Forms that update information on the server, like mailing in feedback
or modifying a database entry, should use POST. Client browsers and intervening proxies are free to cache and refresh the
results of GET requests behind your back, but they may not cache POST requests. GET is only safe for short read-only
requests, whereas POST is safe for forms of any size, as well as for updates and feedback responses. Therefore, by default,
the CGI module uses POST for all forms it generates.
CGI programs are called each time the web server needs a dynamic document generated. It is important to understand that
your CGI program doesn't run continuously, with the browser calling different parts of the program. Each request for a partial
URL corresponding to your program starts a new copy. Your program generates a page for that request, then quits.

A browser can request a document in a number of ways called methods. (Don't confuse HTTP methods with the methods of
object-orientation. They have nothing to do with each other). The GET method is the most common, indicating a simple request
for a document. The HEAD method is used when the browser wants to know about the document without actually fetching it.
The POST method is used to submit form values.

Form values can be encoded in both GET and POST methods. With the GET method, values are encoded in the URL, leading
to ugly URLs like this:


With the POST method, values are in a different part of the HTTP request that the browser sends the server. If the form values
in the example URL above were sent with a POST request, the user, server, and CGI script all see the URL:


The GET and POST methods differ in another respect: idempotency. This simply means that making a GET request for a
particular URL once or multiple times should be no different. This is because the HTTP protocol definition says that a GET
request may be cached by the browser, or server, or an intervening proxy. POST requests cannot be cached, because each
request is independent and matters. Typically, POST requests changes or depends on the state of the server (query or update a
database, send mail, or purchase a computer).

Transferring the Form Data

Parameters to a CGI program are transferred either in the URL or in the body text of the request. The method used to pass
parameters is determined by the method attribute to the <form> tag. The GET method says to transfer the data within the URL
itself; for example, under the GET method, the browser might initiate the HTTP transaction as follows:

     GET /cgi-bin/guestbook.pl?firstname=Joe&lastname=Schmoe HTTP/1.0

The POST method says to use the body portion of the HTTP request to pass parameters. The same transaction with the POST
method would read as follows:

     POST /cgi-bin/guestbook.pl HTTP/1.0
             ... [More headers here]


In both of these examples, you should recognize the firstname and lastname variable names that were defined in the HTML
form, coupled with the values entered by the user. An ampersand (&) is used to separate the variable=value pairs.

The server now passes the variable=value pairs to the CGI program. It does this either through Unix environment variables or
in standard input (STDIN). If the CGI program is called with the GET method, then parameters are expected to be embedded
into the URL of the request, and the server transfers them to the program by assigning them to the QUERY_STRING
environment variable. The CGI program can then retrieve the parameters from QUERY_STRING as it would read any
environment variable (for example, from the %ENV hash in Perl). If the CGI program is called with the POST method,
parameters are expected to be embedded into the body of the request, and the server passes the body text to the program as
standard input (STDIN).

Author Comment

ID: 2736981
What would be better for a form used for a search engine donde in C++?

Author Comment

ID: 2740132
LVL 16

Expert Comment

ID: 2740445
i would suggest you use POST due to the advantages i mentioned above.

Hope that helps.

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
In a question here at Experts Exchange, a member was looking for "a little app that would allow sound to be turned OFF and ON by simply clicking on an icon in the system tray". This article shows how to achieve that, as well as providing the same OF…
The viewer will learn how to count occurrences of each item in an array.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question