Reputation: 665
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
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
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 POST
ed
Upvotes: 1
Reputation: 5913
To loop through each of the POST values, use:
foreach($_POST as $key => $value) {
echo "POST parameter $key has $value";
}
Upvotes: 7