POST and GET (like HEAD, FILE, DELETE, etc.) are HTTP methods . Your browser sends an HTTP request to the server with one of them before the request, so you cannot send two methods at the same time (example request header from a web sniffer):
GET / HTTP/1.1[CRLF] Host: web-sniffer.net[CRLF] Connection: close[CRLF] User-Agent: Web-sniffer/1.0.31 (+http://web-sniffer.net/)[CRLF] Accept-Encoding: gzip[CRLF] Accept-Charset: ISO-8859-1,UTF-8;q=0.7,*;q=0.7[CRLF] Cache-Control: no[CRLF] Accept-Language: de,en;q=0.7,en-us;q=0.3[CRLF] Referer: http://web-sniffer.net/[CRLF]
The big difference from GET and POST is that GET receives a response from url and POST also sends some content data to this URL.When you submit your form, the data is collected in the standard format defined by the enctype attribute and also sent this time on the URL.
Also the url is formatted in a standard way and the part of the string found behind? The character is called QUERY STRING .
When the server receives data, it passes this information to PHP, which reads the URL and reads the method, request body (data) and a huge amount of other things. Finally, it fills its superglobal arrays with this data so you know what the user is sending ( $ _ SERVER , $ _ GET and $ _ POST and many others);
Important notice! In addition, if PHP fills the $ _GET superglobal sum with a URL query string and, ultimately, the $ _POST super switch with the data found in the request body, $ _ POST and $ _GET are not related to HTTP .
So, if you want to fill out $ _ POST and $ _ GET at the same time, you should submit your form as follows:
<form method="post" action="http://myurl/index.php?mygetvar=1&mygetvar=2"> <input name="year" type="text" /> <imput type="submit" /> </form>