表单提交后 $_POST 为空 [英] $_POST is empty after form submission

查看:34
本文介绍了表单提交后 $_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 为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆