[英]HTML form submit sends no data
I have this form: 我有这个表格:
<form action="" method="post" id="login_form">
<input type="text" name="log_login_form"/>
<br/>
<input type="password" name="log_password_form"/>
<br/>
<button type="submit" value="Login" id="log_submit" disabled="disabled" name="action" data-toggle="tooltip" data-placement="bottom">Login</button>
</form>
After a submit the page refreshes, but with php server not getting any data. 提交后页面刷新,但是用php服务器未获取任何数据。
var_dump($_POST);
returns array(0) {}
. 返回
array(0) {}
。
In the form action=""
refers to index.php
that handles form submits. 形式
action=""
是指处理表单提交的index.php
。 (Changing to action="index.php"
didn't help) (更改为
action="index.php"
并没有帮助)
The button has some extra attributes for a script disabling it until all inputs are filled: 该按钮具有脚本的一些额外属性,该脚本在所有输入都被填充之前将其禁用:
login_form.find('input').on('keyup blur', function () {
if (login_form.valid()) {
$('#log_submit').prop('disabled', false);
} else {
$('#log_submit').prop('disabled', 'disabled');
}
});
Removing the script and changing the button to a regular one didn't help either so I guess the problem doesn't lie there. 删除脚本并将按钮更改为常规按钮也无济于事,所以我想问题不在于此。
I've also tried submitting from external button using javascript: <button onclick="document.getElementById('login_form').submit();"></button>
(Ended up with the same behaviour.) 我也尝试过使用javascript从外部按钮提交:
<button onclick="document.getElementById('login_form').submit();"></button>
(最终具有相同的行为。)
And a throwaway try (that I've read, might work) was adding/ removing the /
slashes before closing tags. 一次性尝试(我已经读过,也许可以奏效)是在关闭标签之前添加/删除
/
斜杠。
Could it be a problem with my php configuration? 可能是我的php配置有问题吗?
Thanks for any help. 谢谢你的帮助。
Thanks to Craig 's answer I was able to track down the issue. 多亏Craig的回答,我才能够找到问题所在。 As the form data was there and GET method was working as intended.
当表单数据存在并且GET方法正在按预期工作时。
Turns out it's caused by a bug in an IDE I was using. 原来是我使用的IDE中的错误引起的。 This bit of code fixed the problem:
这段代码解决了这个问题:
$_POST = array(); //workaround for broken PHPstorm
parse_str(file_get_contents('php://input'), $_POST);
(credit: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206999125/comments/203891884 ) (信贷: https : //intellij-support.jetbrains.com/hc/en-us/community/posts/206999125/comments/203891884 )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.