santiago arizti santiago arizti - 24 days ago 11
Apache Configuration Question

Losing php empty post entries

I have a strange situation in one of my servers. Whenever I post a form that contains an empty value for a given post key, when I try to read that key from the $_POST array it is not set as expected.

I expect:

isset($_POST[$k]) == true


But I get:

isset($_POST[$k]) == false


I have not been able to find evidence of this problem anywhere else in the web.

I have two servers and in one of them it happens and in the other one it does not.

I have no idea if it could related to my version of PHP, or Apache, or some configuration file.

Test scenario:

<?php
print_r($_POST['param']);
?>
<form action="posttest.php" method="post">
<input type="text" name="param[text1]" value="1"><br>
<input type="text" name="param[text2]" value=""><br>
<input type="text" name="param[text3]" value="3"><br>
<input type="text" name="param[text4]" value=""><br>
<input type="text" name="param[text5]" value="4"><br>
<button type="submit">Send</button>
</form>


Server A (the good one)



Data:


  • PHP Version 5.4.45



Echoes this:

[param] => Array
(
[text1] => 1
[text2] =>
[text3] => 3
[text4] =>
[text5] => 4
)


Server B (the faulty one)



Data:


  • PHP Version 5.6.20



Echoes this:

[param] => Array
(
[text1] => 1
[text3] => 3
[text5] => 4
)


I don't know what more info to add to the question, so if you have a clue and need more information please let me know and I will update the question

Answer

The problem has disappeared and it was after running an EasyApache on my WHM console. Maybe it was a misconfiguration or a bug in the php binary I was using, who knows.