$_POST vs $_GET

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

$_POST vs $_GET

Post by Draco_03 »

i always used $_POST
i never used get i don t know why i should, and what advantage are they (since it s less secure)

But as everything in php it must be there for a reason...( i'd like to think :P )

so give me your feedback

cheers
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

For smaller things, like e.g. topic number or actual application mode it's quite easy and efficient to use GET. It's simpler to create link than hidden form field with some data that is POST'ed on_submit() :D. I think POST should be used only for large amounts of data like posts, articles, personal questionnaires, and some other things that user shouldn't see or shouldn't be cached in the browser history.
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

Mhh i see...

one thing though when u said get is more "efficient"
do you mean easyer to type OR faster to process ?
Brian
Forum Contributor
Posts: 116
Joined: Thu Apr 18, 2002 5:33 pm

Re: $_POST vs $_GET

Post by Brian »

Since GET request query strings are incorporated directly into URLs, you should use the GET method whenever you want the user to be able to bookmark a page. For example, if you have made a search engine and you want your users to be able to bookmark results pages for quick access, you should use the GET method in your form and your search engine.
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

Draco_03 wrote:do you mean easyer to type OR faster to process ?
Easier to type :D But I think (of course I can be wrong :P) it's also faster to process. The php doesn't have to read the POST data from the stdin, so one read process less, but it is only one process.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

I generally assess the security risk at hand, then make a choice between POST and GET. I also take into consideration if I would like to display the information within the URL even if no security risk is present.

If it's a search engine...GET (?q=term)
If it's a login form...POST
If it's a template system..GET (?page=home)
If it's a email form...POST
etc, etc, etc.
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

Ah :)

Well now i get it.. thx all..
8)
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

2Draco_03
http://www.w3.org/Protocols/rfc2616/rfc2616.txt
In particular, the convention has been established that the GET and
HEAD methods SHOULD NOT have the significance of taking an action other than retrieval.
The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform method to cover the following functions:
- Annotation of existing resources;
- Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles;
- Providing a block of data, such as the result of submitting a form, to a data-handling process;
- Extending a database through an append operation.
Post Reply