Pedro Cordeiro
Pedro Cordeiro

Reputation: 2125

How to redirect a page with POST data

I have two different servers, and I need to send post data from one server to another. But there are some issues that I'll describe below. First, let me describe them:

Now, here's what I'm trying to do:

I don't really know, though, how to redirect my user without 'echoing' a form and submitting it again.

I've done a lot of reading on the subject, and I managed to make my apache send post data using cURL or even using stream_context_create and stream_get_contents, and retrieve the result. What I want to do, though, is redirect my user along with the post data, instead of dispatching a request and displaying the result.

This is not a duplicate of this question, for my files are not in the same server, as q0987's were, making it impossible to store my data in the user's session.

I also realize I can't use header functions to make requests, as the header functions only creates response headers.

I don't have enough privileges to install any libraries on the IIS server (like cURL/libcurl). I can't process the payment on my first server, seeing only the IIS is allowed to access the VISAnet libraries. I also can't put it all on my IIS.

I'm trying to accomplish that with PHP, but I don't even know if what I'm trying to do is possible.

I don't want to write down and submit forms, as it messes up my user's history (and the back button).

Upvotes: 0

Views: 500

Answers (2)

nikita2206
nikita2206

Reputation: 1188

You can't use POST verb for redirecting. I think your problem could be solved with cross-server interaction:

server-1 receives data
server-1 sends data to server-2 and server-2 responds some associated id with that data
server-1 redirects user to server-2 with id in redirect uri query
server-2 receives user's GET request (id is stored in uri query).
server-2 receives data with given id
viola - server-2 knows what server-1 sent to it

Upvotes: 2

eis
eis

Reputation: 53472

What you're asking cannot be done in the way you've described. That is by design, it is not meant to be done that way. If it were possible, it would open up a whole new world of exploits.

You need to either change the approach or then you have misunderstood something crucial about how it is supposed to be done.

Upvotes: 0

Related Questions