Analog post failure Why?
This post was last edited by h420943302 on 2012-12-11 11:18:30
$url = ' Http://127.0.0.1/think_proj/review/index.php/Curl ';
$cookie _id= ' ecs[visit_times]=2;vvxu_2132_saltkey=oaoaiinb;vvxu_2132_lastvisit=1353993212; Vvxu_2132_ulastactivity=1fcbqdogt1v5yt5eratvuz%2bwjv1qvm09zyaqbdb4kl6rkzwornim; lzstat_uv=11374893582414091332|923667; Phpsessid=pcq1alboi8sq3r9n7d32du20m6 ';
$post _fields= ' checkname= '. UrlEncode ($name). ' &checknum= '. $num;
$ch = Curl_init ($url);
curl_setopt ($ch, Curlopt_post, 1);
curl_setopt ($ch, Curlopt_header, 0);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_cookie, $cookie _id);
curl_setopt ($ch, Curlopt_postfields, $post _fields);
$contents = curl_exec ($ch);
Curl_close ($ch); Echo $contents;
Why the output is the pre-submission of the screen, has not been the post of the screen where I wrote the wrong.
------Solution--------------------
Simulating request data
Function Curl ($url, $postfields, $referer = ", $cookie _jar= './cookie.txt ') {
$Cur = Curl_init ();
$Opt = Array (
Curlopt_url = $url,
Curlopt_header = 1,
Curlopt_nobody = 1,
Curlopt_port = 80,//Port
Curlopt_post = 1,//sends a regular POST request with the type: application/x-www-form-urlencoded, just like the form submitted.
Curlopt_postfields = $postfields,//All data to be transferred, if you want to transfer a file, you need a filename at the beginning of the @
Curlopt_returntransfer = 1,//The information obtained is returned in the form of a file stream, rather than as a direct output.
Curlopt_ssl_verifyhost = 1,//Check the existence of SSL encryption algorithm from certificate
Curlopt_ssl_verifypeer = 0,//A check of the source of the certificate, 0 means that the validity of the certificate is blocked.
Curlopt_cookie = Getcook ($url),
Curlopt_useragent = "mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) ",//a string that simulates a user's use of a browser that contains a" user-agent "header in an HTTP request.
Curlopt_useragent = ' mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) gecko/20100101 firefox/9.0.1 ',
Curlopt_followlocation = 1,
Curlopt_cookiejar = Dirname (__file__). $cookie _jar,
Curlopt_cookiefile = Dirname (__file__). $cookie _jar,
Curlopt_referer = $referer,
);
Curl_setopt_array ($Cur, $Opt);
$code = curl_exec ($Cur);
Curl_close ($Cur);
UnSet ($Cur);
Return $code;
}
Function Getcook ($url) {
$Curl =curl_init ($url);
curl_setopt ($Curl, curlopt_header,1);
curl_setopt ($Curl, curlopt_returntransfer,1);
$Cook =curl_exec ($Curl);
Curl_close ($Curl);
$Out = ";
Preg_match ("/ssid\= (. [ ^;] *)/I ", $Cook, $Out);
Return $Out [1];
}
$url = "http://pcik.7di.net/pcik_in";