Solved

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

Posted on 2013-06-14
7
294 Views
Last Modified: 2013-06-14
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?
0
Comment
Question by:LB1234
  • 4
  • 2
7 Comments
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 500 total points
ID: 39247632
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.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39247638
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.
0
 
LVL 1

Author Comment

by:LB1234
ID: 39247642
Why not just use POST all the time though?  They're both equally accessible arrays, why is one better than the other
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39247660
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:

delete.php?key=1234

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.
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 500 total points
ID: 39247671
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:
http://www.w3schools.com/tags/ref_httpmethods.asp
0
 
LVL 58

Expert Comment

by:Gary
ID: 39247687
Excellent examples by Ray
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39247938
Thanks for the points - it's a great question, ~Ray
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Should I use subdomains or addon domains? 3 33
Access Object's Property 9 21
test if query has no results 2 19
html input type 3 21
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

929 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

16 Experts available now in Live!

Get 1:1 Help Now