views:

883

answers:

3

To start: I am a C++ developer who is roped into making a PHP script (for paypal IPN).

I have been incredibly frustrated witht he lack of good working samples from paypal and elsewhere.

The latest problem is that I seem to not get any of the $HTTP_POST_VARS items that I think I should be getting.

Some searches online seem to indicate that this is either deprecated or configurable, etc.

I have no idea what version of PHP is used at my host.

It seems clear that either my testing applications do not post correctly or the script is not working.

so: 2 questions: - Does anyone have any links to working IPN scripts? - What gives with the $HTTP_POST_VARS nonsense?

EDIT

thanks all. I'll try these suggestions out and post up my success story soon I hope.

+1  A: 

First thing to try is changing $HTTP_POST_VARS to $_POST. That's the new mechanism, and after some version or another $HTTP_POST_VARS stopped being a superglobal.

chaos
I believe it was when 5.0 was released, $HTTP_POST_VARS stopped being a global.
R. Bemrose
+2  A: 

You can check what version of PHP you are using by typing phpinfo(); into a PHP script block <?php ?> and see what it ouputs (or simply echo PHP_VERSION).

$HTTP_POST_VARS is the old way of doing things. You can use $_POST['post-var']. To examine everything beint posted, use print_r($_POST).

alex
thanks - I'll try that
Tim
actually, i would recommend var_dump (or var_export) as alternatives to print_r... you get far better information (especially since $_POST is an array)
Hans
@Hans I'll try var_dump() neext time.
alex
+1  A: 

As chaos already wrote, just use the $_POST array instead of $HTTP_POST_VAR.
Two things i like to mention:
1. var_dump(somevar) function is very helpful in php. It displays structured information about somevar. If you not sure how is some variable or array or what ever is structured, just use this function. So this call var_dump($_POST); will display you all the current POST parameters.
2. phpinfo() function is helpful if you are interested which version and extensions is your host using. Just create a file with <?php phpinfo(); ?> in it and navigate with the browser to this file. Don't forget to remove it after this, because of the security leak.

kompozer
I usually like doing....echo "<pre>" . print_r($somevar) . "</pre>";It does the same thing, but prints it in an easier to read format. I think you can do var_dump() in the same spot at print_r(), but it's been a really long time since I've tried.
invenetix
@Inventeix, should that be echo '<pre>' . print_r($somevar, true) . '</pre>'; to get it to return and not simply echo? Maybe it doesn't matter.
alex