This is a discussion on How can I send variables from a PHP script to another URL using POST without using fo within the PHP Programming forums, part of the Web Development category; How can I 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 |
| |||
| How can I send variables from a PHP script to another URL using POST without using forms and hidden variables? I want to know this ASAP...Plz help |
| Sponsored Links |
| |||
|
__________________ J.Vijayanand |
| |||
| 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); ?> This will have the net effect of posting your data to the $URL site, without any header hacking. You can also do other nifty things with cURL, like retrieve the HTML into variables and scrape through it for neat functionality. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/php-programming/2583-how-can-i-send-variables-php-script-another-url-using-post-without-using-fo.html | |||
| Posted By | For | Type | Date |
| Land Refinance - refinance jersey land, land home refinance | This thread | Refback | 11-15-2007 01:16 PM |
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 |
| Can an html and Java script be separated and the script placed in the cgi-bin? | Pvinothkumar | HTML, CSS and Javascript Coding Techniques | 1 | 09-13-2007 06:11 AM |
| How to send variables from a PHP script to another URL, using POST without using form | oxygen | PHP Programming | 1 | 07-26-2007 03:25 AM |
| How to Send Email from a PHP Script Using SMTP Authentication? | Sabari | PHP Programming | 1 | 07-20-2007 05:42 AM |