The $_GET and $_POST variables in PHP are used to retrieve information in a form, such as user input.
Before studying this chapter, you can review the HTML form first
A form is an area containing form elements.
Form elements allow users to enter content in the form, such as text areas, drop-down lists, radio-buttons, checkboxes, etc.
The form uses the form tag
When the user fills out the above form and clicks the submit button, the form data will be sent to the PHP file named "welcome.php" :
welcome.php file is as follows:
Your age is years.
The demonstration of accessing through the browser is as follows:
#We will explain $_GET in PHP in the following chapters and the $_POST variable.
Form Validation
User input should be validated (via client script) whenever possible. Browser validation is faster and reduces the load on the server.
If user input needs to be inserted into the database, you should consider using server validation. A good way to validate a form on the server is to pass the form to itself, rather than jumping to a different page. This way users can get error messages on the same form page. It will be easier for users to find errors.