HTML generally interacts with users on the front page, and PHP can be used to build a server in the background to process data. Now we will use the front-end form to obtain user input, and PHP will perform background processing and return the user information.
(1) You need to build a PHP environment and server, please refer to my first three articlesblog"How to install XAMPP on Mac" "Eclipse Configuring PHP Development Environment" "The First PHP Program - Hello World".
(2) The PHP code is implemented as follows:
<?php echo "用户名:".$_GET['name']."<br>密码:".$_GET['password'];
It will be used later when accessing PHP in HTML.
(4) The HTML form code is implemented as follows:
<meta charset="UTF-8"> <title>表单与PHP交互</title>
.
(6) Then it will jump to another page. The information on this page is the data returned by PHP:
.
(7) In this way, the communication between HTML and PHP is successful. You can see that we use GET to communicate. We can also use POST to communicate, as long as we modify it in HTML and PHP at the same time.
The above introduces the data interaction between HTML forms and PHP, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.