Forum Moderators: coopster

Message Too Old, No Replies

is it possible to redirect with POST values using php

         

topr8

2:34 pm on Oct 2, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



obviously it is possible to easily POST data to another webpage/resource using CURL, however CURL doesn't redirect the user.

is it possible to do a redirect and include POST data.

... my situation is that we have a form on page a, which is POSTed to page b for processing
both a & b are on the same website on our server. on page b we want to insert all the POSTed values into a db and then redirect the user to page c and send POST data to page c at the same time (page c is on a different server and is not under our control)
i'm thinking this is not possible.

i can serve page b as a blank page except for the form and hide it in a hidden div, with javascript to submit the form on load, (javascript is required to have even got to this point, so i'm not worried about users that don't have it), which is quick but a bit clunky - i fear this is the best solution though.... i'd rather do it without the page 'b' loading in the browser!

whitespace

11:41 am on Oct 5, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



A "redirect" is a GET request. So you can't send a POST and a GET request "at the same time". You could redirect after having sent the POST request, but how do you link the two?

Presumably this other server is expecting a POST request, and this is fixed?

It really depends on what the process is and what this other server is doing. Presumably the other server is sending a response? Is it just a case of serving this response to the client (which is probably "page c") or do you need to get the user to this other site?

topr8

12:10 pm on Oct 5, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



thanks for explaing that a redirect is a GET, that makes sense!

yes, the user must go to the other site. ... it is a gateway payment page.

whitespace

12:26 pm on Oct 5, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



... it is a gateway payment page.


Do they not provide some instructions for the expected procedure?

topr8

6:42 am on Oct 8, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



yes, they suggest trapping the data for myself, then serving a page with a form (hidden fields) and a button, which the user has to click.

i'm just of the old school, where i like as few steps as possible for the customer to spend their money.

... i've gone with serving the form in a hidden div on a blank page and using javascript to submit the form ... there is a slight delay and the user sees a white/blank page very briefly before the redirect but it works well enough.