Home > Backend Development > PHP Tutorial > How to receive data from form in php?

How to receive data from form in php?

怪我咯
Release: 2023-03-10 19:10:01
Original
5669 people have browsed it

PHP The data submitted by the form can be obtained through the POST and GET methods.
The obtained POST and GET are values ​​in the form of array, which need to be obtained in detail through key values. The corresponding value

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>
Copy after login
<?php
//获取表单提交的数据
$contents = $_POST[&#39;contents&#39;];
echo $contents;
?>
Copy after login

It can also be the following is the GET method

<form name="form1" method="get" action="index.php">
<input type="text" name="contents" value="">
<input type="submit" value="提交">
</form>
Copy after login
<?php
//获取表单提交的数据
$contents = $_GET[&#39;contents&#39;];
echo $contents;
?>
Copy after login

POST is relative to GET The method is better, can submit a large amount of data, and is more safer.

The above is the detailed content of How to receive data from form in php?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template