Search code examples
phppostvar-dump

$_POST and $_GET not working on var_dump but working on loggued requests


I have a very simple form like I've done dozens, but this one isn't working for a reason that eludes me. When var_dumping the $_POST variable after submit it's empty but it's working on the request_maker from chrome. here is where it is submited:

echo "  <form method='POST'>
            <input type='button' class='button' style='height:50px' name='manage' value='export' onclick='submit()'/>
            </form>";
    var_dump($_POST);

the var_dump returns an empty array.

From other subjects I've seen they talk about php.ini wich was unchanged since a long time on my side, no updates were made, and others post requests on different pages are working


Solution

  • The problem is that you are not POSTing the form when you press the button. You are performing the onclick event.

    Remove the onclick attribute (or make sure that the submit() function is POSTing).