Home > Article > Backend Development > How to submit HTML form to PHP file
How to submit HTML form to PHP file?
The first step is to create a folder form in the www directory, and create the files form_submit.html and receive.php in the folder.
The second step is to open the file form_submit.html and enter the code. This code mainly uses the form form, and the method attribute of the form form is "post". Note that the encoding format must be set correctly, otherwise garbled characters will appear.
The third step is to open the file receive.php and enter the code. The code mainly uses PHP's built-in function $_POST().
The fourth step is to open the file form_submit.html in the browser and enter the data to submit. You can jump to the php page and display the data.
In form_submit.html, if the method attribute of the form form is set to "get", then receive.php will use Built-in function $_GET().
Notes
The utf8 format must be set in both files, otherwise garbled characters will appear
Also use the built-in function $_REQUEST () to achieve the same effect.
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to submit HTML form to PHP file. For more information, please follow other related articles on the PHP Chinese website!