问题
this must be configuration issue and I'm hoping somebody can help. I'm setting up a new project on my localhost and my PHP Post is always empty. Here's the example:
My Form Page:
<form id="loginForm" action="/post/login" method="post">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" value="Submit" />
</form>
and the "/post/login/index.php" page:
<?php
var_dump( $_POST );
?>
the result:
array(0) { }
It seems like there's no code issue so what's the problem?
回答1:
The action attribute needs to point to the actual script of the page you want to go to.
Try doing this instead:
<form id="loginForm" action="/post/login/index.php" method="post">
来源:https://stackoverflow.com/questions/16306870/php-form-post-always-empty