1

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?

8
  • Do you need to add value attributes to each of your <input> tags? Commented Apr 30, 2013 at 18:45
  • 3
    Does it work if you do action="/post/login/index.php"? Try using a debugger like Fiddler or Firebug to see if your POST is being sent. Commented Apr 30, 2013 at 18:46
  • 1
    No errors in your logs? Commented Apr 30, 2013 at 18:46
  • 1
    do you clicked submit and then it redirects to "/post/login/index.php" but didn't shows anything? Commented Apr 30, 2013 at 18:47
  • 2
    I can't believe it - @Rocket Hazmat had the solution with adding "index.php". Really odd as it clearly navigates to the correct page. If you add that as an answer, I'll accept it. Commented Apr 30, 2013 at 18:50

1 Answer 1

3

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">
Sign up to request clarification or add additional context in comments.

5 Comments

Great catch, I wonder why PHP isn't sending the post to index.php without it being explicitly defined... hmm.
I'm not sure. Probably something to with it being redirected and not passing the values to the redirect.
And I like to hide my server scripting language as much as possible... so this is a bit annoying
@Andrew: I'm sure there's a way to fix it, but I'm not sure.
Update: The following also works "/post/login/". So it seems the filename is required or the trailing slash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.