Home  >  Article  >  Backend Development  >  Master the correct way to use POST in PHP

Master the correct way to use POST in PHP

autoload
autoloadOriginal
2021-04-25 11:05:004068browse

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>

Master the correct way to use POST in PHP

php verification page: test.php

<?php

$name=$_POST[&#39;username&#39;];
$pass=$_POST[&#39;password&#39;];
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!

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