Home>Article>Backend Development> What are PHP forms for?
What is the PHP form for?
PHP super global variables $_GET and $_POST are used to collect form data (form-data).
PHP - A simple HTML form
The example below shows a simple HTML form that contains two input fields and a submit button:
Example
When the user fills out this form and clicks the submit button, the form data will be sent to a PHP file named "welcome.php" for processing. Form data is sent via the HTTP POST method.
To display the submitted data, you can simply echo all variables. The "welcome.php" file looks like this:
Welcome
Your email address is:
Output:
Welcome Bill Your email address is Bill.Gates@example.com
The same result can be obtained using the HTTP GET method:
Example
"welcome_get.php" is like this:
Welcome
Your email address is:
The above code is very simple. However, the most important part was left out. You need to validate your form data to prevent vulnerabilities in your scripts.
Note: Please pay attention to security when processing PHP forms!
This page does not contain any form validators, it only shows us how to send and receive form data.
For more PHP related knowledge, please visitPHP Chinese website!
The above is the detailed content of What are PHP forms for?. For more information, please follow other related articles on the PHP Chinese website!