Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

<form method="post">

Hey community, can anyone explain to me what that method attribute stands for and what's the meaning of post and get?

Thank you in advance, Patrick :-)

2 Answers

This is the method used to send the form data to the server. To keep it as simple as possible :

  • GET : The data is written at the end of the URL (it's called the query string). This is used mostly to retrieve data from the server, for example if the form is a search field.
  • POST : The data is encoded in the body of the http request. it is used mostly to write to the server.

Here is what quora has to say about it.

Hope this helps.

Thank you :-)

post and get are two http request types you can send to the server. There are others, but let's not go there now.

Get requests send data via the url. This is unsecure, as you'd image. But it's great for say, filtering data. You've seen the URLs like www.mydomain.com?size=large&color=red&delivery=tomorrow

This url has 3 get variables, size, color, and delivery. You could have a form that allowed your user to choose these types of variables, and that form would make a get request to the server, which would/could return data based on the values of the get variables. In this case, it would only show widgets that are large sized, red, and can be delivered tomorrow. (Whatever a widget is). This is great, but Suzy can copy the URL and send it to Bob, and when Bob opens it, he sees the same filtered list of widgets.

Post requests are more secure. These would be things like contact, or login forms. Post request data goes into the request body, where it's not easily visible. You can make this even more secure by having an SSL certificate installed on your server. Post requests do not show up in the url, but you can do basically anything you need to or want to with the data on the server, including creating or updating records on the server, sending an email, or returning data based on the post variables.

Thank you too, for helping me out :)