-4

Possible Duplicate:
When should I use GET or POST method? What’s the difference between them?

I am creating a newsletter subscription area for my website and I'm wondering which method is preferred?... GET or POST? Since I'm allowing people to register their emails for future newsletters, I figured that GET would be the preferred method but I hear alot of people just say use POST for everything.

I know GET is faster, less secure and can't store as many characters.

What do you think? GET or POST?

Edit: I know this post will probably be downvoted to oblivion since it is a rather simple question but I am asking the preferred way. Not just some half ..... way!

Community
  • 1
  • 1
Codist
  • 1,198
  • 2
  • 11
  • 28
  • "GET is faster" — no, it isn't. "less secure" — make sure you understand what the security limitations are rather than focusing on such a broad statement. "can't store as many characters" — you're passing *an email address* not a copy of War & Peace. (You shouldn't use GET, but your reasons are all wrong) – Quentin Oct 02 '12 at 22:24
  • For an example of where GET is definitely the bad option: http://thedailywtf.com/Articles/The_Spider_of_Doom.aspx – Marc B Oct 02 '12 at 22:24
  • @Quentin those weren't my reasons for thinking about using GET. This is the reason why I created this post to find out the correct information about GET and POST. I fairly new to these methods and I don't want to use them incorrectly like half the internet does. – Codist Oct 02 '12 at 22:28
  • @Quentin No it is not a possible duplicate of that! I'm asking what method is preferred for a newsletter subscription box... Not what the difference is between them! – Codist Oct 02 '12 at 22:29
  • @W3Geek — Which should be used for a newsletter subscription box can be very easily inferred from the differences between them (at least as expressed by the accepted answer on that question) – Quentin Oct 02 '12 at 22:49

5 Answers5

5

Generally use POST if you want to insert or update something. GET if you want to retrieve data. If you are letting people sign up by submitting a form with their email address you should use POST.

TheMethod
  • 2,893
  • 9
  • 41
  • 72
2

POST is generally used to modify data on the server, GET should generally return data and be idempotent.

Steve H.
  • 6,912
  • 2
  • 30
  • 49
1

The technology differences between the two are essentially minimal. You might run into a limitation or odd implementation here or there, but your primary concern should be the semantic meaning of the API you're exposing.

Every web page, every web service, any resource accessible online is an API that the owner is exposing to the world. That API should follow standards and conventions wherever possible in order to be more easily understood by anybody who wishes to consume that API.

Taking a look at the definitions for HTTP verbs:

  • GET: The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in the response and not the source text of the process, unless that text happens to be the output of the process.
  • POST: 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.

Essentially... If you're retrieving data, use GET. If you're inserting data (which is your case), use POST. There are more, of course. To modify data use PUT, to get metadata about data, use HEAD, to remove data use DELETE, you get the idea.

David
  • 208,112
  • 36
  • 198
  • 279
-1

both are ok, however mails will be hold in history by GET, if you dont want this, you should use POST

alpera
  • 509
  • 4
  • 9
-1

While POST amd GET would both work the actual preferred way is POST. Both method's have their limitation but in this case both of them wont limit your implementation because it will be a somewhat "simple" page.

Use a get to tell the server what to do, not to set the data. And yes you are right the user can read the GET but they also can read/modify your post so no point in taking that in consideration.

Just follow the standarts and use a POST.

For more info see the following pages:

http://www.w3schools.com/php/php_post.asp
http://www.w3schools.com/php/php_get.asp
http://www.cs.tut.fi/~jkorpela/forms/methods.html
Unnamed
  • 54
  • 4