SWD Technical Solutions - Atlantic Franchise Swellendam



Home arrow SMS Make Text BiggerMake Text SmallerReset Text Size
Contact Us - ADSL - Hosting - Domains - Sign up - Live Help

How can I send variables from a PHP script to another URL using POST without using forms and hidden

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($Host80, &$errno, &$errstr);
if (!
$socket)

$Result["errno"] = $errno;
$Result["errstr"] = $errstr;
return 
$Result;
}
$idx 0;
fputs($socket$ReqHeader);
while (!
feof($socket))

$Result[$idx++] = fgets($socket128);
}
//-------------------------------------------
?>

Or you can use the cURL extensions for PHP (http://curl.haxx.se). 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($chCURLOPT_URL,"https://$URL"); 
curl_setopt($chCURLOPT_POST1);
curl_setopt($chCURLOPT_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.

To use cURL you need to recompile PHP or check with your ISP to see if they support it (Fatboys does)
 
Tag it:
Delicious
Furl it!
Spurl
digg
Blinkbits
BlinkList
blogmarks
co.mments
connotea
De.lirio.us
digg
Fark
feedmelinks
LinkaGoGo
Ma.gnolia
Netvouz
NewsVine
RawSugar
Reddit
Shadows
Simpy
Smarking
TailRank
Wists
YahooMyWeb
< Prev   Next >
Related Items

Joomla Template by Chris Bruce - Fatboys Team