Using Load post in jquery and so on cannot get the desired result! So suddenly ----- I thought about things in the past few days, so now I have.
If you want to submit data to the specified page in PHP, there should be and return values.
So I found this function, but I didn't try it. I don't know if the space can be used.
It's from the village!
CopyCode The Code is as follows: <? PHP
/*-----------------------------------------------------------
* Function: Use PHP socke to submit data to a specified page.
*
* Author: Honghe. c
*
* Description: post ($ URL, $ data)
*
* $ Url = 'HTTP: // www.jb51.net ';
* $ Data [user] = 'Hong ';
* $ Data [pass] = 'xowld ';
* 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 (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 open socket to $ URL [host]";
Fputs ($ FP, sprintf ("post % 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 .. 200", $ 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 );
*/
?>