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['PHP_SELF'];?>"/> Name:<input type="text" name="fname"/> <input type="submit"/> </form> <?php $name= $_POST['fname']; 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!