2

I was wondering if anyone could help me solve how to view $_POST requests.

What i want to do, is check all $_POST requests, not just certain ones like $_POST['name'], $_POST['post'] etc, I'd like to check every post, without being able to know the name of each POST request.

Here is what i've tried (snippet):

foreach ($_POST as $pst)
{
    echo $pst;
}
//And tried the above for GET too. (but the GET I've manged to working.)

I've also tried many others, that i can think off an can come to no resolution...

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390

2 Answers2

7

You used the right solution

foreach($_POST as $key=>$value){
    //> do your operation here
    echo $key.': '.$value;
}

You can use $key to get the param name

dynamic
  • 46,985
  • 55
  • 154
  • 231
2

If you're just looking to output the posts so you can see them to troubleshoot something then i'd use something like this:

<?php
    echo "<pre>\n";
    print_r($_POST);
    echo "</pre>\n";
    exit;
?>
Dan
  • 3,750
  • 5
  • 24
  • 38
  • Thanks Dan, I should of made my post clearer, but i'd like to analyze the post content. Example: if($_POST == "hello world")...Without knowing the POST request's name – RobAtStackOverflow May 31 '11 at 18:15