This is a discussion on How to send variables from a PHP script to another URL, using POST without using form within the PHP Programming forums, part of the Web Development category; How to send variables from a PHP script to another URL, using POST without using forms and hidden variables?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| You can open an HTTP socket connection and send HTTP POST commands. Here is an example : <? // Generate the request header $ReqHeader = "POST $URI HTTP/1.1\n". "Host: $Host\n". "Content-Type: application/x-www-form-urlencoded\n". "Content-Length: $ContentLength\n\n". "$ReqBody\n"; // Open the connection to the host $socket = fsockopen($Host, 80, &$errno, &$errstr); if (!$socket) $Result["errno"] = $errno; $Result["errstr"] = $errstr; return $Result; } $idx = 0; fputs($socket, $ReqHeader); while (!feof($socket)) $Result[$idx++] = fgets($socket, 128); } //------------------------------------------- ?> Or you can use the cURL extensions for PHP (cURL and libcurl). Once you build it and compile their support into PHP, it is fairly easy to do posting stuff (even over https): <? $URL="www.mysite.com/test.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://$URL"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "Data1=blah&Data2=blah");curl_exec ($ch); curl_close ($ch); ?> |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to get the Post values without using Server Variables? | senraj | PHP Programming | 6 | 10-17-2007 11:31 PM |
| How to send data from servlet to javascript variables | Pvinothkumar | HTML, CSS and Javascript Coding Techniques | 0 | 10-09-2007 11:05 PM |
| How to select a value from a child form and send it to parent form? | GDevakii | ASP and ASP.NET Programming | 1 | 09-20-2007 10:14 PM |
| How can I send variables from a PHP script to another URL using POST without using fo | kingmaker | PHP Programming | 2 | 07-24-2007 02:58 AM |
| How to Send Email from a PHP Script Using SMTP Authentication? | Sabari | PHP Programming | 1 | 07-20-2007 05:42 AM |