Useful notes & manuals
from the
world wide web
Register now!
Submit a form using POST method through PHP PHP
Solution from: unknown Created on 18.07.2024 @ 23:48

To submit a form using POST method through PHP, just add the data to be posted as header. This essentially saves one extra html page sent to the browser when user has to be redirected. Mostly found this technique useful for redirecting to payment gateways. 

$host = "";
$path = "/path/to/script.php";
$data = "data1=value1&data2=value2";
$data = urlencode($data);

header("POST $path HTTP/1.1rn" );
header("Host: $hostrn" );
header("Content-type: application/x-www-form-urlencodedrn" );
header("Content-length: " . strlen($data) . "rn" );
header("Connection: closernrn" );

submit   form   method   post   payment   gateway   redirect   header
Created by THE LOST WEB © 2009-2012