Posting variable without form
| From: | Then Nam Kheong | Date: | Mon, 26 Aug 2002 16:26:49 +0000 |
| Subject: | Posting variable without form | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-114153@lists.php.net to get a copy of this message | ||
Hello,
I saw searching in the archive for posting variable without using a
form.
I saw the answer by one of you, which is in this link:
http://www.faqts.com/knowledge_base/view.phtml/aid/12039/fid/51
The code is actually a senttohost() function:
=========================================================
function sendToHost($host,$method,$path,$data,$useragent=0)
{
// Supply a default method of GET if the one passed was empty
if (empty($method))
$method = 'GET';
$method = strtoupper($method);
$fp = fsockopen($host,80);
if ($method == 'GET')
$path .= '?' . $data;
fputs($fp, "$method $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n");
if ($useragent)
fputs($fp, "User-Agent: MSIE\n");
fputs($fp, "Connection: close\n\n");
if ($method == 'POST')
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
return $buf;
}
=========================================================
I tried it but it is not successful. I think it is because I tried to
post to a https(SSL link).
I would like to know if I can perform a SSL posting using the above
code, or if anyone could point to me how I can post variables without
using a form, please point to me.
Thanks.
--
Best regards,
Then Nam Kheong
nkthen@singnet.com.sg