$_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 为空


基础教程推荐
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01