How to find out the POST variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jiop
Forum Newbie
Posts: 11
Joined: Wed Dec 18, 2002 4:00 am
Location: newport beach

How to find out the POST variables

Post by jiop »

Is there any way to find out which POST variables are being sent to the your browser?

I'm trying to run an authentication script off another server but it requires me to capture one of the variables that is sent..
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

being sent to the your browser
:?: to the browser?

Code: Select all

<html><body><pre>
<?php print_r($_POST); ?>
</pre></body></html>
Malder
Forum Newbie
Posts: 13
Joined: Wed Mar 19, 2003 11:09 pm

Post by Malder »

$_POST is a associative array of variables passed to the current script via the HTTP POST method so use this:
<?php
foreach($_POST as $v) echo $v;
?>
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Malder wrote:$_POST is a associative array of variables passed to the current script via the HTTP POST method so use this:
<?php
foreach($_POST as $v) echo $v;
?>
Missing some "{}" there..?
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

McGruff: If and when you use either if,for,while,foreach, etc that uses one line, you don't need the { }'s.

Example:

Code: Select all

<?php
for ($i = 0; $i < 10; $i++)
  echo $i;
?>
or

Code: Select all

<?php
while ($i != 4)
  $i++;
?>
If the loops uses more then one line of code, then you have to include the {}s.
Image Image
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Best to always include braces though - leads to less mistakes (i.e. when you add a second line) and makes the code easier to read, IMHO.

Mac
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Thanks Phice I didn't know that.
Post Reply