简体   繁体   中英

Why is $_POST empty in PHP5 under Apache?

In the file http://example.com/path/foo.php , I have the form (formatting deleted):

<form action="/path/foo.php" method="post">
Email: <input type="text" name="email">
Password: <input type="password" name="password">
<input type="checkbox" name="remember" checked="checked"> Remember me
<input type="submit" value="Log In">
</form>

Sometimes users are not able to log in: the reported behavior was that they tried to log in and were presented with a fresh login screen.

When I've been able to duplicate the problem, it appears $_POST is empty: $_POST['email'] and $_POST['password'] lack the submitted values, and the following just logs "##":

error_log("#" . file_get_contents("php://input") . "#");

I can't see why this would be due to a redirect; it can't be a case of /directory -> /directory/ , and a look through Apache's relevant VirtualHost section turned up very little rewriting, and not any that should affect the file. (And the displayed URL is the same as the one referenced in the form.)

The system has been around for a few months and the problem was first reported to me today.

I'm planning on emerging updated Apache and PHP(5), in case there's a fluke that could be improved by a more recent version. But I'd be very interested in hearing other ways I might be getting an empty $_POST after filling out a form.

Thoughts?

If, as you've said to Lucky, you can confirm this is a FF issue then have your users disable all their plugins/addons and try again. It could be they have some conflicts there.

Is the data available in the $_REQUEST variable? I know it's not POST-specific, but it should be populated with the posted data.

Do you have 'register_globals' enabled? This a horrible security hole which would cause your POSTed data to be assigned to $email and $password instead of existing in the $_POST array.

If this optioned is enabled, disabling it will cause your script to run correctly and remove the potential security threat.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM