PHP经常性地使用信息传输,这也是PHP为实现动态网页应运而生地缘由,对于信息量极少的,我们可能会使用GET,但是数据内容较多时我们会使用POST,本文就带大家一起来看一看。
首先我们先写一个html页面:
<!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验证页面:test.php
立即学习“PHP免费学习笔记(深入)”;
<?php $name=$_POST['username']; $pass=$_POST['password']; echo "用户名:".$name."<br>"; echo "密码:".$pass."<br>"; ?>
输出:用户名:lilil 密码:4561212
推荐:《2021年PHP面试题大汇总(收藏)》《php视频教程》
以上就是掌握正确使用PHP中POST的方法的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号