Home >Backend Development >PHP Problem >How to submit HTML form to PHP file

How to submit HTML form to PHP file

藏色散人
藏色散人Original
2019-11-01 10:26:126332browse

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.

How to submit HTML form to PHP file

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.

How to submit HTML form to PHP file

The third step is to open the file receive.php and enter the code. The code mainly uses PHP's built-in function $_POST().

How to submit HTML form to PHP file

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.

How to submit HTML form to PHP file

How to submit HTML form to PHP file

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().

How to submit HTML form to PHP file

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!

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