HTTP: is the Hypertext Transfer Protocol(HTTP) enables the communication between client and server. It has a request-response protocol for communication. The request sent by the client is responded by the server.
The HTTP methods used are:
The set of commands are as follows:
This article explains : GET, POST & PUT methods.
- GET: This command is mainly used to get data from the resource. This command sends data as a part of the URL, it appends the form data into the URL in the name/value pairs. The length of the URL is limited to 2048 characters. We should not use GET method if password or any sensitive information is there in the server. Mainly useful for form submission where the user want to bookmark the result. Get is better for non-secure data like query things in Google. GET can’t be used to send binary data like images etc.
The syntax is
<form action=”some.php” method=”GET”>
For example consider a simple example accepting name and password
2. POST method:
POST is used to send the information from the server or to the server. Let us see one example of passing information through post method.
- Create a notepad file to write a simple program using html .
- Use method post and input type name and company name text fields and a submit button.
- Save the file.
- Run the file.
The design of the form looks as above where the name and company fields has to be passed to a file called post.php.
And run the file and the post method passes the information without showing it in the URL and gets the result.
The main difference between get and post method the get method displays the information passed in the URL where as post method hides the information in the URL.there are various advantages in this post method , there is no restrictions for the data size to be sent.we can sent binary data and uses the http protocol which is secure method of passing information .
3. PUT method
It is an Idempotent method, we can send multiple requests with PUT, but will not affect server and same request can be sent multiple times, it will update data. It tries to identify the resource with request.
Consider an example to request using PUT in php
The client side request is sent as a blank request
The server side response will be like