Home  >  Article  >  Backend Development  >  Data interaction between HTML form and PHP

Data interaction between HTML form and PHP

WBOY
WBOYOriginal
2016-07-29 09:14:371949browse

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[&#39;name&#39;]."<br>密码:".$_GET['password'];

(3) Get the link address of the PHP server, which is the link address after you run the program. For example, mine is: http://localhost/MyPHPServer/Server.php

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>



    
用户名:
密 码:

(5) Then run the HTML code and enter the username and password.

Data interaction between HTML form and PHP.

(6) Then it will jump to another page. The information on this page is the data returned by PHP:

Data interaction between HTML form and 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.

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
Previous article:centos 65 install php569Next article:centos 65 install php569