Andrew Andrew - 4 months ago 16
PHP Question

PHP Form post always empty

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?

Answer

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">