[php]
//fsocket simulates get submission
$gurl = "http://localhost/php/t.php?uu=gggggg";
//print_r(parse_url($gurl));
echo "The following is the response content in GET mode:
";
sock_get($gurl);
function sock_get($url)
{
$info = parse_url($url);
$fp = fsockopen($info["host"], 80, $errno, $errstr, 3);
$head = "GET ".$info['path']."?".$info["query"]." HTTP/1.0rn";
$head .= "Host: ".$info['host']."rn";
$head .= "rn";
$write = fputs($fp, $head);
while (!feof($fp))
{
$line = fgets($fp);
echo $line."
";
}
}
//fsocket simulates post submission
$purl = "http://localhost/php/t.php";
echo "The following is the response content in POST mode:
";
sock_post($purl,"uu=rrrrrrrrrrr&&kk=mmmmmm");
function sock_post($url, $query)
{
$info = parse_url($url);
$fp = fsockopen($info["host"], 80, $errno, $errstr, 3);
$head = "POST ".$info['path']." HTTP/1.0rn";
$head .= "Host: ".$info['host']."rn";
$head .= "Referer: http://".$info['host'].$info['path']."rn";
$head .= "Content-type: application/x-www-form-urlencodedrn";
$head .= "Content-Length: ".strlen(trim($query))."rn";
$head .= "rn";
$head .= trim($query);
$write = fputs($fp, $head);
while (!feof($fp))
{
$line = fgets($fp);
echo $line."
";
}
}
?>
Requested response page t.php
[php]
if(isset($_GET['uu'])){
echo 't.php The value of $_GET["uu"] is: '.$_GET['uu']."
";
}
if(isset($_POST['uu'])){
echo 'The value of $_POST int.php is:
';
Print_r($_POST);
}
?>
The following are the results:
The following are the results of Firebug:
Author: Fanteathy