Php simulates post to submit data. Php simulates post submission of data, which is very useful. it can be used for website Collection, login, and so on. taking the Forum logon in my project as an example functionA_bbslogin ($ user_login, $ password, $ host, $ port80) {php is required to simulate post submission of data, which is of great use and can be used for website Collection and login.
// Take the Forum logon in my project as an example
Function A_bbslogin ($ user_login, $ password, $ host, $ port = "80 "){
// The post data to be submitted
$ Argv = array (
'Cookies' => array ('User _ login' => $ user_login, 'password' => $ password, '_ wp_http_referer' => '/bbpress /', 're' => '', 'Remember '=> true)
);
Foreach ($ argv ['cookies'] as $ key => $ value ){
$ Params [] = $ key. '='. $ value;
}
$ Params = implode ('&', $ params );
$ Header = "POST/bbpress/bb-login.php HTTP/1.1 \ r \ n ";
$ Header. = "Host: $ host: $ port \ r \ n ";
$ Header. = "Content-Type: application/x-www-form-urlencoded \ r \ n ";
$ Header. = "Content-Length:". strlen ($ params). "\ r \ n ";
$ Header. = "Connection: Close \ r \ n ";
$ Header. = $ params;
$ Fp = fsockopen ($ host, $ port );
Fputs ($ fp, $ header );
While (! Feof ($ fp) {// LieHuo29.Net
$ Str = fgets ($ fp); // The following is your own logic code. here we simulate cookies for synchronous login.
If (! (Strpos ($ str, "Set-Cookie:") === false )){
$ Tmparray = explode ("", $ str );
$ Cookiearray = explode ("=", $ tmparray [1]);
$ Cookiepaths = explode ("=", $ tmparray [6]);
$ Cookiename = urldecode ($ cookiearray [0]);
$ Cookievalue = urldecode (substr ($ cookiearray [1], 0, strlen ($ cookiearray [1])-1 ));
$ Cookietime = time () + 3600*24*7;
$ Cookiepath = urldecode (substr ($ cookiepaths [1], 0, strlen ($ cookiepaths [1])-1 ));
Setcookie ($ cookiename, $ cookievalue, $ cookietime, $ cookiepath );
}
}
Fclose ($ fp );
}
Address: http://www.52blogger.com/archives/595
Login // take the forum login in my project as an example function A_bbslogin ($ user_login, $ password, $ host, $ port = 80) {// Yes...