user3289157
user3289157

Reputation: 665

PHP variable length of POST request?

I am trying to submit an html form to a php server. However, this form can have a variable length and structure (I add input nodes through dynamic javascript as the user interacts with the page, depending on his actions). How can I pick up the values contained in the form from PHP (using $_POST['xxx']) if I don't know the structure of the form?

Upvotes: 1

Views: 2809

Answers (4)

pistou
pistou

Reputation: 2867

echo '<pre>';
print_r($_POST);
echo '</pre>';

Easy and clean.

Upvotes: 0

sumanth kumr
sumanth kumr

Reputation: 1

To find the structure of the POST OR GET OR SESSION values, you can print using

echo "<pre>"; print_r($_POST); print_r($_REQUEST); print_r($_SESSION);

You can find easily what exactly printing/structure of POST/REQUEST/SESSION.. etc

Upvotes: 0

Hanky Panky
Hanky Panky

Reputation: 46910

Just a fun (but valid) answer, existing answer on this question is good enough.

if I don't know the structure of the form?

Then you can simply review

print_r($_POST);

and you'll get to know the structure of what was POSTed

Upvotes: 1

Brett Gregson
Brett Gregson

Reputation: 5913

To loop through each of the POST values, use:

foreach($_POST as $key => $value) {
  echo "POST parameter $key has $value";
}

Upvotes: 7

Related Questions