- /**
- * PHP in the Curl analog post submission
- * by bbs.it-home.org
- */
- $url = ' http://website/a.php ';
- $fields = Array (
- ' UserName ' =>urlencode (' a '),
- ' PWD ' =>urlencode (' B '),
- ' Appreturn ' =>urlencode (' C '),
- ' Appsql ' =>urlencode (' d '),
- );
- $fields _string = Http_build_query ($fields);
- $ch = Curl_init ();
- curl_setopt ($ch, Curlopt_url, $url); Set the URL to collect
- curl_setopt ($ch, curlopt_post,1); Set form to post
- curl_setopt ($ch, Curlopt_postfields, $fields _string);//Set Post parameters
- curl_setopt ($ch, curlopt_returntransfer,1); Print it out with a string.
- $re = curl_exec ($ch);//(if Curlopt_returntransfer is not set to 1, the contents of the HTML document will be executed and fetched, such as: 1; otherwise the result will be returned, not executed)
- Print_r ($re);
- $info = Curl_getinfo ($ch);//Request Information
- Print_r ($info);
- $data = Array (' UserName ' = ' bar ');
- $data = Http_build_query ($data);
- $opts = Array (
- ' http ' = = Array (
- ' Method ' = ' POST ',
- ' Header ' = ' content-type:application/x-www-form-urlencoded\r\n '.
- "Content-length:". Strlen ($data). "\ r \ n",
- ' Content ' = $data
- ),
- );
- $context = Stream_context_create ($opts);
- $html = File_get_contents ($url, False, $context);
- Echo $html;
- Var_dump ($http _response_header);
Copy Code>>> Read more: PHP implements the code for simulating get and post requests PHP using the socket, curl, file_get_contents method post data instance PHP $_get $_post parameter length limit PHP Curl in post with Get application instance code PHP Curl Post Simple example PHP Curl implementation Get,post and cookie Instance code PHP receive parameters and get POST original data method Php Curl Submit Get,post, A simple example of a cookie PHP $_get,$_post,$_request and $_server usage php batch processing post value method PHP form post parameter automatically add escape character problem solution PHP implementation post PHP Curl simulates post transfer data function PHP Curl analog POST Request example PHP Fsockopen analog post-commit code |