sending the data to another server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Blondy
Forum Commoner
Posts: 32
Joined: Thu Mar 06, 2008 5:55 pm

sending the data to another server

Post by Blondy »

hi guys i've gt below code

Code: Select all

function post($host, $path, $data) { 
$http_response = ''; 
$content_length = strlen($data); 
$fp = fsockopen($host, 80); 
fputs($fp, "POST $path HTTP/1.1\r\n"); 
fputs($fp, "Host: $host\r\n"); 
fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n"); 
fputs($fp, "Content-Length: $content_length\r\n"); 
fputs($fp, "Connection: close\r\n\r\n"); 
fputs($fp, $data); 
while (!feof($fp)) $http_response .= fgets($fp, 28); 
fclose($fp); 
return $http_response; 
} 
 
$postdata = '?foo=bar'; 
foreach($_POST as $key => $val) $postdata .= '&'.$key.'='.$val; 
 
$http_response = post('example.org', '/path/to/script.php', $postdata); 
 
I want to ask how much this posting method is secure
and how the response lenght could be?
thanks
and as a hint if you know how I code encrypt this code cause i'm gonna use this code for activating my script
thanks
User avatar
aditya2071990
Forum Contributor
Posts: 106
Joined: Thu May 22, 2008 11:30 am
Location: Hyderabad, India
Contact:

Re: sending the data to another server

Post by aditya2071990 »

Well paypal uses the same concept: posting data to another server, for their website payments standard buttons.

But I reckon you better use https:// connections, for encryption and stuff...
Blondy
Forum Commoner
Posts: 32
Joined: Thu Mar 06, 2008 5:55 pm

Re: sending the data to another server

Post by Blondy »

and what about response if anybody knows
Post Reply