$_POST is empty after form submission(表单提交后 $_POST 为空)
问题描述
我在我的服务器上设置了这个测试页面.请告诉我为什么即使我提交表单,$_POST
数组也不包含任何内容.我已经在三种不同的浏览器中尝试过这个,但没有任何反应.
I set up this test page up on my server. Please tell me why the $_POST
array does not contain anything even when I submit the form. I have tried this in three different browsers and nothing happens.
<?php print_r($_POST);?>
<form method="post">
<p><label>Email: </label>
<input type="text" id="login_email" />
</p>
<p><label>Password: </label>
<input type="password" id="login_password" />
</p>
<p><label>Remember Me?: </label>
<input type="checkbox" id="login_remember" />
</p>
<p>
<input type="submit" value="Login" />
</p>
</form>
我已经写 PHP 多年了,以前从未发生过这种情况.这段代码有什么问题?
I have been writing PHP for years and this has never happened before. What is wrong with this code?
推荐答案
您的输入元素没有名称属性.应该是:
Your input elements do not have name attributes. Should be:
<input type="text" id="login_email" name="login_email" />
如果一个 input 元素没有 name 属性,它不会作为 POST 数据的一部分发送.
If an input element does not have a name attribute, it is not sent as part of the POST data.
这篇关于表单提交后 $_POST 为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:表单提交后 $_POST 为空


- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01