Lotuspandiyan
Lotuspandiyan

Reputation: 109

PHP : How to get all variable name in php post method

I would like to get and display all variable names which are posted by method="post" in a form. I am not aware of variables which passed from post method in HTML. Is there any method to list the all variables posted by post method ?.. Thanks in advance.

example: http://www.dhamu.in/oncreate2.php?workload=10&request_type=project&name=web%20design&description=we%20have%20done%20it&budget=1&bidperiod=11&project_guidelines=checked&job_113=1&xxxx=10 Here i do no the variable name "xxxx"

Upvotes: 9

Views: 30853

Answers (3)

iambriansreed
iambriansreed

Reputation: 22261

Try:

print_r(array_keys($_POST))

... for just the keys.

Or:

print_r($_POST)

... for all the POST keys and values.

Upvotes: 5

Christian Strempfer
Christian Strempfer

Reputation: 7383

To output all POST variables, try this:

var_dump($_POST);

Variables which are included within the URL are GET variables actually:

var_dump($_GET);

Upvotes: 1

Brad Christie
Brad Christie

Reputation: 101614

foreach ($_POST as $key => $value){
  echo "{$key} = {$value}\r\n";
}

And BTW, those are $_GET variables (so adjust the above to use foreach ($_GET as $key => $value){.) You can also use $_REQUEST to cover both.

Upvotes: 21

Related Questions