Home > Article > Backend Development > Master the correct way to use POST in PHP
PHP
frequently uses information transmission, which is why PHP
came into being to realize dynamic web pages. For those with very little information , we may use GET
, but when the data content is large, we will use POST
. This article will take you to take a look.
First we write an html page:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <form action="test.php" method="POST"> <label for="username">账号:</label> <input type="text" id="username" name="username"> <label for="password">密码:</label> <input type="text" id="password" name="password"> <input type="submit" value="提交"> </form> </body> </html>
php verification page: test.php
<?php $name=$_POST['username']; $pass=$_POST['password']; echo "用户名:".$name."<br>"; echo "密码:".$pass."<br>"; ?>
输出:用户名:lilil 密码:4561212
Recommendation:《2021 PHP interview questions summary (collection)》《php video tutorial》
The above is the detailed content of Master the correct way to use POST in PHP. For more information, please follow other related articles on the PHP Chinese website!