Theoretical question------------------

What is difference between get and post request in form submission

1 Like

When submitting form data to a web server, there are two HTTP methods that can be used: GET and POST.

The main difference between GET and POST requests is how the form data is sent to the server.

In a GET request, the form data is sent in the URL query string, which is visible in the address bar of the web browser. GET requests are typically used for retrieving information from the server. For example, when you search for something on Google, the search query is sent via a GET request.

In a POST request, the form data is sent in the HTTP request body, which is not visible in the address bar. POST requests are typically used for submitting data to the server, such as when you fill out a form with personal information and submit it to a website.

Another difference is that GET requests can be cached, while POST requests cannot be cached. This means that if you make the same GET request twice, the response may be served from the cache instead of being sent to the server again. POST requests, on the other hand, cannot be cached because they can potentially change the state of the server.

In summary, if you’re retrieving data from the server, use a GET request. If you’re submitting data to the server, use a POST request.

2 Likes