$_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 为空
基础教程推荐
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何替换eregi() 2022-01-01
