[英]Php form post method not sending data
I have a simple HTML form, which is actually working well on my localhost and in few servers. 我有一个简单的HTML表单,该表单实际上在我的localhost和少数服务器上都能正常工作。 But last time I put it in my code, I understood that it doesn't send data with
POST
, although I have written the method="post"
. 但是上次我将其放入代码中时,虽然我已经编写了
method="post"
,但我知道它不会通过POST
发送数据。 This is first time I meet this problem, and I don't know if it is from my side or from server. 这是我第一次遇到此问题,并且我不知道这是从我这边还是从服务器。 When I dump
GLOBAL
param $_SERVER
in my localhost, the param REQUEST_METHOD
is POST
, but when I dump it on server it is GET
. 当我在本地主机中转储
GLOBAL
参数$_SERVER
时,参数REQUEST_METHOD
是POST
,但是当我将其转储到服务器上时是GET
。 I also tried to change the method in .htaccess
, but no result. 我也尝试更改
.htaccess
的方法,但没有结果。 Here is my form: 这是我的表格:
<form action="/auth/login" method="post">
<div id="error">
<?
if (isset($errors)) {
foreach ($errors as $error) {
echo $error . "<br>";
}
}
if (isset($invalid)) {
echo $invalid;
}
?>
</div>
<div id="login-box-name" style="margin-top:20px;">Login:</div>
<div id="login-box-field" style="margin-top:20px;">
<input name="login" class="form-login" type="text"/>
</div>
<div id="login-box-name">Password:</div>
<div id="login-box-field">
<input name="password" type="password" class="form-login"/>
</div>
<br />
<input type="image" src="/images/login-btn.png" width="103" height="42" style="margin-left:90px;" />
</form>
And on server when I print $_POST
or $_POST['login']
they are empty, although I have passed params. 在服务器上,当我打印
$_POST
或$_POST['login']
它们是空的,尽管我已经传递了参数。
public function action_login() {
echo "<pre>";
var_dump($_SERVER); // this is returns server data, where REQUEST_METHOD is GET on current server, but POST in my local
var_dump($_POST); // this is empty
echo "</pre>";
}
Is that from server or hosting configuration? 是服务器还是主机配置?
Try this 尝试这个
<form action="auth/login" method="POST">
<div id="error">
<?
if (isset($errors)) {
foreach ($errors as $error) {
echo $error . "<br>";
}
}
if (isset($invalid)) {
echo $invalid;
}
?>
</div>
<div id="login-box-name" style="margin-top:20px;">Login:</div>
<div id="login-box-field" style="margin-top:20px;">
<input name="login" class="form-login" type="text"/>
</div>
<div id="login-box-name">Password:</div>
<div id="login-box-field">
<input name="password" type="password" class="form-login"/>
</div>
<br />
<input type="submit" src="/images/login-btn.png" width="103" height="42" style="margin-left:90px;" value="save" />
</form>
您缺少关键字:type =“ submit”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.