php method of receiving the form
PHP can obtain the data submitted by the form through the POST and GET methods
The obtained POST and GET are values in the form of arrays. You need to obtain the corresponding values in detail through key values.
For example: index.php page
The following is the POST method
<form name="form1" method="post" action="index.php"> <input type="text" name="contents" value=""> <input type="submit" value="提交"> </form> <?php //获取表单提交的数据 $contents = $_POST['contents']; echo $contents; ?>
It can also be the GET method
<form name="form1" method="get" action="index.php"> <input type="text" name="contents" value=""> <input type="submit" value="提交"> </form> <?php //获取表单提交的数据 $contents = $_GET['contents']; echo $contents; ?>
Compared with the GET method, POST is better, can submit a large amount of data, and is more secure.
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to receive form in php. For more information, please follow other related articles on the PHP Chinese website!