Home >Backend Development >PHP Tutorial >PHP study notes (2)_PHP tutorial
PHP’s $_GET and $_POST are used to retrieve values in forms, such as user input.
Form example:
The $_GET variable is an array whose content is the variable name and value sent by the HTTP GET method
The $_GET variable is used to collect values from the form with method="get". Information sent from a form with the GET method is visible to everyone (displayed in the browser's address bar), and there is a limit on the amount of information sent (maximum 100 characters).
The "welcome.php" file can now retrieve form data via the $_GET variable and the name of the form field will automatically become the ID key in the $_GET array:
Note: When using $_GET variables, all variable names and values will appear in the URL. So this method should not be used when sending passwords or other sensitive information. However, because the variables appear in the URL, you can bookmark the page. In some cases this is useful.
The HTTP GET method is not suitable for large variable values; values cannot exceed 100 characters.
PHP's $_REQUEST variable contains the contents of $_GET, $_POST and $_COOKIE.
PHP's $_REQUEST variable can be used to obtain the results of form data sent via GET and POST methods.
The $_POST variable is used to collect values from the form with method="post". Information sent from a form with the POST method is invisible to anyone (it does not appear in the browser's address bar), and there is no limit on the amount of information sent.