Question

I have a form in my webpage that allows the customer to enter some data. When the user submits the form, my php script in server A now adds some other params that I do not want the client to be able to see and posts to my Server B payment system. What I want to do might seem like this I saw in some other question:

Client --> Server A

           Server A --> POST --> Server B

Client <------------------------ Server B

Server B needs no session or anything for it to work, it directly takes users to a form where they will set up their payment data. How can I accomplish this? Is there any alternative?

Thank you very much.

Was it helpful?

Solution

What you are trying is not possible. Server B has no knowledge of the Client, so there is no way it can communicate with it. You should build it like this:

Client --> Server A

           Server A --> POST --> Server B
           Server A <-- REPLY <-- Server B

Client <-- Server A

In (pseudo)code, on Server A:

function handleRequest($postdata) {
    $reply = sendPostToServerB($secrets);

    return $reply;
}

$r = handleRequest($_POST);
$stufftosendtoclient = process($r);

echo $stufftosendtoclient;

When you do this, be wary of timing problems. If Server B is slow, it might cause issues in the client. You could try to handle this in an Ajax call and give the user at least more info and control of what is going on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top