I have been trying to post data to a URL (https) but no luck. I'm using the following function.
Wondering if anything is wrong in this. Anyone can help ?
function post($data) {
$host = 'www.xxxxxxx.com';
$path = '/test/testform';
$http_response = '';
$content_length = strlen($data);
$fp = fsockopen($host, 443,$errno, $errstr);
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, $data);
fputs($fp, "Connection: close\r\n\r\n");
while (!feof($fp)) $http_response .= fgets($fp);
fclose($fp);
echo " hello...< $http_response ...> $data";
echo " ... $errno ... $errstr ...";
return $http_response;
}
Post Data to URL
Moderator: General Moderators
Re: Post Data to URL
I think this is best way for your purpose :
create HTML form and then submit it . (with javascript and php)
create HTML form and then submit it . (with javascript and php)
Re: Post Data to URL
not sure what you mean using javascript & php. I have very huge form which I validate and post it using a function.
If you have a sample with javascript could you please share.
If you have a sample with javascript could you please share.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact: