lguenier
lguenier

Reputation: 187

$_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

Upvotes: 1

Views: 2203

Answers (2)

Antony D&#39;Andrea
Antony D&#39;Andrea

Reputation: 1004

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).

Upvotes: 2

kamlesh.bar
kamlesh.bar

Reputation: 1804

var_dump($_POST) 

Only works when you submit form. so change code as mention below you will able to dump data

if(isset($_POST)){
   var_dump($_POST);
}

also put action in form Tag

action="<?php echo $_SERVER['PHP_SELF']; ?>"

Other Thing try put Input field to get clear idea

 <input type="text" name="name"><br>

Upvotes: 0

Related Questions