Click to See Complete Forum and Search --> : Post a php variable without using form


vijiruba
04-03-2006, 06:22 AM
How to post a php variable without using form and hidden fields?

chrisranjana
04-03-2006, 06:37 AM
Can you let us know exactly what you are trying to accomplish so that we can help you.

vijiruba
04-03-2006, 06:50 AM
<?php
$Host="viji";
$ReqBody="ssssssssssssssss";
$URI="/home/viji/vijiruba/assignments/12.php";
$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($Host, 7070,&$errno, &$errstr);
echo "<br>".$socket;
if (!$socket)
{
$Result["errno"] = $errno;
$Result["errstr"] = $errstr;
return $Result;
}
//$idx = 0;
fputs($socket, $ReqHeader);
while(!feof($socket))
{
$buf = fgets($socket,128);
echo "<br>".$buf;
}
?>

This is the code i hav typed and im getting this error:



HTTP/1.1 404 Not Found
Date: Mon, 03 Apr 2006 11:47:02 GMT
Server: Apache/2.0.52 (Unix) PHP/4.3.9
Vary: accept-language,accept-charset
Accept-Ranges: bytes
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1
Content-Language: en
X-Pad: avoid browser bug

Zipline
04-03-2006, 07:44 AM
Look into CURL:
http://us3.php.net/curl