With the load post in jquery and so on, I can't get the results I want! So suddenly-----all the things I think about these days, and now I have to.
Now you want to submit the data to the specified page in PHP, you should have it, and you can have a return value
So I found this function, but did not try, I think I can not know whether the space can pass through
It was brought by the village!
Copy Code code as follows:
<?php
/*-----------------------------------------------------------
* Function: Use PHP Socke to submit data to the specified page
*
* Author: honghe.c
*
* Description: Post ($url, $data)
*
* $url = ' http://www.jb51.net ';
* $data [user] = ' ";
* $data [Pass] = ' Xowldo ';
* Echo Post ($url, $data);
*-----------------------------------------------------------*/
Function post ($url, $data) {
$url = Parse_url ($url);
if (! $url) return "couldn ' t parse url";
if (!isset ($url [' Port ']) {$url [' port '] = "";}
if (!isset ($url [' query ']) {$url [' query '] = ' ";}
$encoded = "";
while (the list ($k, $v) = each ($data)) {
$encoded. = ($encoded? "&": "");
$encoded. = Rawurlencode ($k). = ". Rawurlencode ($v);
}
$fp = Fsockopen ($url [' Host '], $url [' Port ']? $url [' Port ']: 80);
if (! $fp) return "Failed to the open socket to $url [host]";
Fputs ($FP, sprintf ("POST%s%s%s http/1.0n", $url [' Path '], $url [' query ']? "?": "", $url [' query ']]);
Fputs ($FP, "Host: $url [host]n");
Fputs ($fp, "Content-type:application/x-www-form-urlencodedn");
Fputs ($FP, "Content-length:". Strlen ($encoded). "N");
Fputs ($fp, "Connection:closenn");
Fputs ($fp, "$encodedn");
$line = fgets ($fp, 1024);
if (!eregi ("^HTTP/1. ", $line)) return;
$results = ""; $inheader = 1;
while (!feof ($fp)) {
$line = fgets ($fp, 1024);
if ($inheader && ($line = = "N" | | | $line = = "RN")) {
$inheader = 0;
}
ElseIf (! $inheader) {
$results. = $line;
}
}
Fclose ($FP);
return $results;
}
/*
$url = ' http://video.xxx.com:80/game_vm.php ';
$data [' gid '] = ' 1 ';
Echo Post ($url, $data);
*/
?>