Home  >  Article  >  Backend Development  >  php $_POST receives form data example code

php $_POST receives form data example code

怪我咯
怪我咯Original
2017-07-12 13:53:122336browse

In PHP, the predefined $_POST variable is used to collect values ​​from the form with method="post". Below I will bring you an example of PHP using super global variable $_POST to receive form data. The following is the code:

<!doctype html>
<html>
<head>
<title>利用超级全局变量$_POST接收表单</title>
<meta http-equiv="content-type" contnet="text/html" charset="utf-8"/>
</head>
<body>
<form method="post" action="<?php echo $_SERVER[&#39;PHP_SELF&#39;];?>"/>
Name:<input type="text" name="fname"/>
<input type="submit"/>
</form>
<?php
$name= $_POST[&#39;fname&#39;];
echo $name;
?>
</body>
</html>

The output content uses the post method to submit the data, and then uses $_POST['fname']; to receive the data and assign it to the global variable of $name,

Then use echo to output $name; the variable gets the final result, which is the content in the form. .............

The above is the detailed content of php $_POST receives form data example code. 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