Andrew Andrew - 1 year ago 72
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" />

and the "/post/login/index.php" page:

var_dump( $_POST );

the result:

array(0) { }

It seems like there's no code issue so what's the problem?

Answer Source

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