PHP Form Methods

For uploading data some PHP Form Methods are used such as Get or Post. These methods are written as value of method attribute and specifies the HTTP method to be used when submitting the form data.

Both GET and POST are treated as $_GET and $_POST. These are superglobals, which means that they are always accessible, regardless of scope – and you can access them from any function, class or file without having to do anything special.

The array of variables given to the current script via URL parameters is known as $_GET.

The array of variables given to the current script via the HTTP POST method is known as $_POST.

The default method is Get method.

PHP Form Methods

When to use PHP Form Method GET?

For sending form data as URL variables the Get method is used, the data sent using $_GET method is visible to everyone. The quantity of data that can be sent with GET is similarly limited. The character count is restricted at around 2000. It is feasible to bookmark the website because the variables are displayed in the URL. In some circumstances, this can be beneficial.

Note: GET is used to send non-sensitive information .GET should never be used to send passwords or other confidential data!

When to use Post?

For sending the data as HTTP post transaction Post method is used, the data sent using $_Post method is not visible to everyone. There are no restrictions on the number of data that can be sent via Post.

Furthermore, while uploading files to the server, POST enables features such as support for multi-part binary input.

However In case of Post method, bookmarking the page is not feasible because the variables are not displayed in the URL.

Note: For transmitting form data, developers prefer POST.

Visit GET VS POST for more differences.