問題:
$ _POST數組爲空,即使文件( 「PHP://輸入」);返回值正確(見下文)
我的形式:
<form class="form-horizontal" name="loginform" method="post" action="<?= $_SERVER['PHP_SELF']; ?>">
<div class="form-group">
<label for="">Username</label>
<input class="form-control" type="text" step="any" name="username" value="">
</div>
<div class="form-group">
<label for="">Password</label>
<input class="form-control" type="password" step="any" name="password" value="">
</div>
<div class="form-group">
<input class="btn btn-warning" type="submit" name="submit" value="Submit">
</div>
</form>
<?php
$mypostdata = file("php://input");
print "<pre>";
var_dump($_POST);
var_dump($mypostdata);
print "</pre>"
?>
我的輸出:
array(0) { } array(1) { [0]=> string(46) "username=aravind&password=secret&submit=Submit" }
檢查以下線程:http://stackoverflow.com/questions/1282909/php-post-array-empty-upon-form-submission –