note 89447 added to function.header

From: Date: Sun, 08 Mar 2009 06:17:46 +0000
Subject: note 89447 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-151623@lists.php.net to get a copy of this message
Found this script after much despair, should be useful to lot of people. 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.1\r\n" ); header("Host: $host\r\n" ); header("Content-type: application/x-www-form-urlencoded\r\n" ); header("Content-length: " . strlen($data) . "\r\n" ); header("Connection: close\r\n\r\n" ); header($data); ?> ---- Server IP: 203.199.69.133 Probable Submitter: 118.94.99.80 ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- https://master.php.net/note/edit/89447 Del: integrated -- https://master.php.net/note/delete/89447/integrated Del: useless -- https://master.php.net/note/delete/89447/useless Del: bad code -- https://master.php.net/note/delete/89447/bad+code Del: spam -- https://master.php.net/note/delete/89447/spam Del: non-english -- https://master.php.net/note/delete/89447/non-english Del: in docs -- https://master.php.net/note/delete/89447/in+docs Del: other reasons-- https://master.php.net/note/delete/89447 Reject -- https://master.php.net/note/reject/89447 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#151623) next »