<?php /* Send POST request to https://secure.example.com/form_action.php * Include form elements named "foo" and "bar" with dummy values */
$sock = fsockopen("ssl://secure.example.com", 443, $errno, $errstr, 30); if (!$sock) die("$errstr ($errno)\n";
$data = "foo=" . urlencode("Value for Foo") . "&bar=" . urlencode("Value for Bar");
fputs($sock, "POST /form_action.php HTTP/1.0\r\n"); fputs($sock, "Host: secure.example.com\r\n"); fputs($sock, "Content-type: application/x-www-url-encoded\r\n"); fputs($sock, "Content-length: " . strlen($data) . "\r\n"); fputs($sock, "Accept: */*\r\n"); fputs($sock, "\r\n"); fputs($sock, "$data\r\n"); fputs($sock, "\r\n");
$headers = ""; while ($str = trim(fgets($sock, 4096))) $headers .= "$str\n";
print "\n";
$body = ""; while (!feof($sock)) $body .= fgets($sock, 4096);
fclose($sock); ?>
|