Why would one ever use "get" method in PHP?

I just don't understand the point of this feature.  Why would I ever care about putting information in a link, when i Could just link to a page directly?
Who is Participating?
Ray PaseurConnect With a Mentor Commented:
Actually, GET and POST are not the same.  Get is informational.  Post can be informational, and it can also change the data.  Here is the classic example of a GET fail.

You write a script to delete a row from the data base, based upon the key.  If it is a GET-method request, the URL might look like this:


You create an administrative page that lists all of the rows in the data base.  It has one line for each row, with links to update scripts as well as the delete script.  Someone posts a link to your administrative page somewhere (anywhere) and Google picks it up.  As Google spiders the administrative page, it follows all of the links on the page.

Poof!  Your data base is gone.

Here is the classic example of a POST fail.  Visit the web site of Fairfax County, VA, USA.  Use the site to look up real estate tax information.  When you find the data you want, try to send a link to a colleague.  You can't, because the county's misdesigned web site uses POST requests instead of GET requests to process the form information.  You also cannot bookmark the real estate tax information.  It has to be looked up, over and over again, manually.
Ray PaseurConnect With a Mentor Commented:
Uhh, because you were creating a page that provided a general purpose search facility, for example.  The GET method request makes sense if your intent is to retrieve data, without changing the data model on the server.
GET is used to pass information between pages, the same as POST.  The only difference is that using GET exposes that information in the URL while POST passes the information invisibly.
Security wise they are exactly the same.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

LB1234Author Commented:
Why not just use POST all the time though?  They're both equally accessible arrays, why is one better than the other
Ray PaseurConnect With a Mentor Commented:
You choose GET so you can have bookmarks.  In that way, a single general-purpose script can serve several purposes.  Think of an online catalog.  A single script can show you all of the items in the catalog (probably using the SKU is a GET-method key).

Some good discussion here:
Excellent examples by Ray
Ray PaseurCommented:
Thanks for the points - it's a great question, ~Ray
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.