Welcome! Log In Create A New Profile

Advanced

Accessing HTTP POST variables

Posted by Roger Dunk 
Roger Dunk
Accessing HTTP POST variables
June 13, 2008 12:15AM
Hi all,

While I'm waiting for PC Soft to respond, perahps somewhere here can tell me how to access HTTP POST data in a WebDev page? i.e. the equivilent of PHP's $_POST["xxx"] array.

SysEnvironment() will reveal the HTTP GET query string, but not POST data.

Thanks,
Roger
KenKnight
Re: Accessing HTTP POST variables
June 13, 2008 05:31PM
Hi Roger,

Variable's coming in through a post should be accessible via the control name, so for example lets say I had a hidden field name pageID that had data I needed.. in webdev I'd simply reference it directly;

trace(pageID)

variables passed via the command line or parameter string would be referenced via;

myString = PageParameter("myString")

or

myString = PageParameter("P1")

HTH

Cheers!
Ken
Roger Dunk
Re: Accessing HTTP POST variables
June 14, 2008 01:26AM
Hi Ken,

It seems PageParameter() can be also be used on POST variables, and should serve my purpose in this instance, thanks.

A separate variable (array) storing only HTTP POST data, and another storing HTTP GET query string data (a la PHP etc) would make a lot more sense however. With PageParamater() I need to firstly check QUERY_STRING in SysEnvironment() to make sure it's not a HTTP GET query string, before I can assume the data has come via POST. Isn't WebDev supposed to make our life more simple?

And how to quickly show all HTTP POST variables that have been sent to a page? It's print_r($_POST) in PHP. Can it even be done in WebDev? Arrrrrgh!

Cheers...
Roger

PS. FWIW, I'm implementing PayPal's Instant Payment Notification for a web site. PayPal does an HTTP POST to a web page to verify the payment details. I'm beginning to think I may as well just use a PHP script, and use the HyperFile ODBC driver to store the results in my database. <sigh>
KenKnight
Re: Accessing HTTP POST variables
June 14, 2008 08:54PM
Hi Roger,

Similarly, you could also check the value of "REQUEST_METHOD" to determine whether its a POST or GET and act accordingly.

Cheers!
Ken
Roger Dunk
Re: Accessing HTTP POST variables
June 14, 2008 11:55PM
Hi Ken,

Yes, I must have missed REQUEST_METHOD. Certainly it's a much better idea for checking the type of request, thanks.

In any event, for the time being I've implemented PayPal IPN using PHP. PayPal requires that every variable that gets POSTed to your page, is POSTed back to PayPal (to verify where the request came from). Since there are a large number of variables coming from PayPal, it's so much easier to simply loop through a POST array to create the data to POST back to PayPal, as opposed to manually creating the data from each individual variable. Furthermore, by looping through a POST array, I am automatically future-proofing this part of the process. If PayPal changes or adds a variable, I am still covered.

Cheers...
Roger

KenKnight
Re: Accessing HTTP POST variables
June 15, 2008 12:08AM
Agreed, that will be much easier. If I come up with a solution I'll post it to this thread.

Cheers!
Ken
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: