PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Here is the problem. You see the print_r statement? When that statement is there, I can see that 'button' is set and the if statement returns true and the block of code is executed. Without the print_r statement, the if statement is false because 'button' doesn't exist and "fail" gets printed. This makes no sense at all.
Doesn't seem to make much sense, does it? Because I don't have functions.php to include, I removed that line and also replaced the first two lines from inside the if block with echo 'success';.
Unlike you, I found that removing print_r() made no difference whatsoever to the logical outcome. That makes me think that a problem exists with either the setFormData() function, or the code within page.php, or possibly both.