Solved

Info

Posted on 2000-04-18
5
216 Views
Last Modified: 2013-12-25
What is the difference between Post and Get?
0
Comment
Question by:bea_pr
  • 2
  • 2
5 Comments
 

Expert Comment

by:venky75
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.

Bye
Venky
0
 
LVL 16

Accepted Solution

by:
maneshr earned 10 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:

http://mox.perl.com/cgi-bin/program?name=Johann&born=1685

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:

http://mox.perl.com/cgi-bin/program

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]

     firstname=Joe&lastname=Schmoe

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).
0
 

Author Comment

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

Author Comment

by:bea_pr
ID: 2740132
thanx
0
 
LVL 16

Expert Comment

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

Hope that helps.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The viewer will learn how to dynamically set the form action using jQuery.
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now