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.
<?php $host = "www.example.com"; $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" ); header($data); ?>
|