Home>Article>Backend Development> What are PHP forms for?

What are PHP forms for?

藏色散人
藏色散人 Original
2019-10-21 09:37:28 3643browse

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

  
Name:
E-mail:

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

  
Name:
E-mail:

"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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn