PHP Redirect with POST data

后端 未结 13 1456
不思量自难忘°
不思量自难忘° 2020-11-22 06:22

I did some research on this topic, and there are some experts who have said that it is not possible, so I would like to ask for an alternative solution.

My situation

相关标签:
13条回答
  • 2020-11-22 07:20

    Try this:

    Send data and request with http header in page B to redirect to Gateway

    <?php
    $host = "www.example.com";
    $path = "/path/to/script.php";
    $data = "data1=value1&data2=value2";
    $data = urlencode($data);
    
    header("POST $path HTTP/1.1\\r\
    " );
    header("Host: $host\\r\
    " );
    header("Content-type: application/x-www-form-urlencoded\\r\
    " );
    header("Content-length: " . strlen($data) . "\\r\
    " );
    header("Connection: close\\r\
    \\r\
    " );
    header($data);
    ?>
    

    Additional Headers :

    Accept: \*/\*
    User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like 
    Gecko) Chrome/74.0.3729.169 Safari/537.36
    
    0 讨论(0)
提交回复
热议问题