php $_POST receives form data example code

怪我咯
Release: 2023-03-13 17:40:01
Original
2414 people have browsed it

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>
Copy after login

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!

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