简体   繁体   中英

Redirecting php post reply to client

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM