[PHP] $_POST issues
Hello, Can someone explain me what this piece of code basically does ? ?php header(Expires: . gmdate(D, d M Y H:i:s, time() + (0*60)) . GMT); header(Pragma: no-cache); print REDIRECT=http://www.domaine.com/page.php?;; $param = http_build_query($_POST); print $param; exit(0); ? Well, the code is redirecting to some page with query string constructed using the $_POST data. My problem is not the redirection; but all I want is to get the data in $_POST If I just put only this piece of code: ?php var_dump($_POST); ? i get nothing. But the above codes is successfully redirecting me to page.php with a properly constructed query string - which means that $_POST was never empty. So why var_dump($_POST) is returning just array(0) { } ??? nadim attari alienworkers.com
Re: [PHP] $_POST issues
On 1 December 2010 14:50, Bundhoo M Nadim na...@alienworkers.com wrote: Hello, Can someone explain me what this piece of code basically does ? ?php header(Expires: . gmdate(D, d M Y H:i:s, time() + (0*60)) . GMT); header(Pragma: no-cache); print REDIRECT=http://www.domaine.com/page.php?;; $param = http_build_query($_POST); print $param; exit(0); ? Well, the code is redirecting to some page with query string constructed using the $_POST data. My problem is not the redirection; but all I want is to get the data in $_POST If I just put only this piece of code: ?php var_dump($_POST); ? i get nothing. But the above codes is successfully redirecting me to page.php with a properly constructed query string - which means that $_POST was never empty. So why var_dump($_POST) is returning just array(0) { } ??? nadim attari alienworkers.com Under normal circumstances, $_POST will only be populated from a form with a method=post. So, loading a URL to a PHP script containing just the var_dump() will never output anything for $_POST as the URL wasn't the result of a POST'd form. You can also use cURL or stream_contexts to construct the data for POST-ing and your script would receive these correctly. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_POST issues
On Wed, Dec 1, 2010 at 09:50, Bundhoo M Nadim na...@alienworkers.com wrote: If I just put only this piece of code: ?php var_dump($_POST); ? i get nothing. But the above codes is successfully redirecting me to page.php with a properly constructed query string - which means that $_POST was never empty. So why var_dump($_POST) is returning just array(0) { } ??? Are you actually posting data to it? -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_POST issues
On 01/12/2010 19:01, Daniel P. Brown wrote: On Wed, Dec 1, 2010 at 09:50, Bundhoo M Nadimna...@alienworkers.com wrote: If I just put only this piece of code: ?php var_dump($_POST); ? i get nothing. But the above codes is successfully redirecting me to page.php with a properly constructed query string - which means that $_POST was never empty. So why var_dump($_POST) is returning just array(0) { } ??? Are you actually posting data to it? Actually this is the response page, i.e. a payment gateway is sending the result of a transaction to this page. Normally I expect to catch the data sent by the payment gateway using the $_POST array, i.e. $result = $_POST['result'], etc. So i wanted to check the data sent by the payment gateway using var_dump($_POST); --- this gives me array(0) { } But if I put the other codes (lemme quote again here): filename: response.php ?php header(Expires: . gmdate(D, d M Y H:i:s, time() + (0*60)) . GMT); header(Pragma: no-cache); print REDIRECT=http://www.domaine.com/page.php?;; $param = http_build_query($_POST); print $param; exit(0); ? It successfully redirects me to page.php + the properly constructed query string e.g.: http://www.domain.com/page.php?var1=val1var2=val2 ... etc That's baffling me. Why can't I catch the $_POST data in this response.php but I get them in page.php ?? Something weird. nadim attari alienworkers.com
Re: [PHP] $_POST issues
?php var_dump($_POST); ? Where exactly are you putting this line? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] $_POST issues
[snip] If I just put only this piece of code: ?php var_dump($_POST); ? i get nothing. [/snip] Where are you putting this var_dump? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_POST issues
On 1 December 2010 15:18, Marc Guay marc.g...@gmail.com wrote: ?php var_dump($_POST); ? Where exactly are you putting this line? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If a script is ran via a url like ... http://www.site.com/script.php?var1=val1var2=val2 then $_GET will contain the result. The same $_GET would hold the values from a form method=get $_POST is for POST-d data (either via form method=post or cURL/Streams). -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_POST issues
On 12/01/2010 07:18 PM, Jay Blanchard wrote: [snip] If I just put only this piece of code: ?php var_dump($_POST); ? i get nothing. [/snip] Where are you putting this var_dump? That's the only code on the page. Otherwise, the other codes - header(), print, etc. are on the page. nadim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_POST issues
The function http_build_query() is turning your $_POST array into a query string ($_GET), so the answer to this really depends where you're trying to dump the array. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_POST issues
On 1 December 2010 14:50, Bundhoo M Nadim na...@alienworkers.com wrote: Hello, Can someone explain me what this piece of code basically does ? ?php header(Expires: . gmdate(D, d M Y H:i:s, time() + (0*60)) . GMT); header(Pragma: no-cache); print REDIRECT=http://www.domaine.com/page.php?;; $param = http_build_query($_POST); print $param; exit(0); ? Well, the code is redirecting to some page with query string constructed using the $_POST data. My problem is not the redirection; but all I want is to get the data in $_POST If I just put only this piece of code: ?php var_dump($_POST); ? i get nothing. But the above codes is successfully redirecting me to page.php with a properly constructed query string - which means that $_POST was never empty. So why var_dump($_POST) is returning just array(0) { } ??? nadim attari alienworkers.com I'd start reading http://docs.php.net/manual/en/reserved.variables.php -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] $_POST issues
[snip] Where are you putting this var_dump? That's the only code on the page. Otherwise, the other codes - header(), print, etc. are on the page. [/snip] var_dumping the POST on the same page from which the data originates will not yield anything. Page A - contains data to be posted. Page B - receives posted data (do var_dump here) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_POST issues
This thread is a really good example of how difficult it can be to both explain and understand a problem. The original poster might want to restate the question from scratch with a more explicit and complete example. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_POST issues
On Wed, 2010-12-01 at 20:18 +0400, Nadim Attari wrote: On 12/01/2010 07:18 PM, Jay Blanchard wrote: [snip] If I just put only this piece of code: ?php var_dump($_POST); ? i get nothing. [/snip] Where are you putting this var_dump? That's the only code on the page. Otherwise, the other codes - header(), print, etc. are on the page. nadim if i follow correctly, your form submits via: form method=post action=response.php then you redirect to the page.php, and it puts the $_POST variables into the url string... and that works fine. and now, you're trying to get the variables from the page.php, using the $_POST method? wouldn't you want to be checking the $_GET on this page, as they would be coming in from the url string? Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php