Why does post simulation fail?

Source: Internet
Author: User
Why does post simulation fail? This post was last edited by h420943302 from 2012-12-11:18:30 & lt; form & nbsp; actionindex. phparticipant letest & nbsp; methodpost & gt; & lt; tr & gt; & lt; td & nbsp; why does the post simulation fail?

This post was last edited by h420943302 at 11:18:30 on

 

$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 do I output all the images before submission? why can't I get the post image ..
------ Solution --------------------
// Simulate 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, // send a regular POST request in the type of application/x-www-form-urlencoded, just like submitting a form.
CURLOPT_POSTFIELDS => $ postfields, // all the data to be transferred. to transfer a file, a file name starting with @ is required.
CURLOPT_RETURNTRANSFER => 1, // The obtained information is returned in the form of a file stream, rather than directly output.

CURLOPT_SSL_VERIFYHOST => 1, // check whether the SSL encryption algorithm exists from the certificate
CURLOPT_SSL_VERIFYPEER => 0, // checks the certificate Source. 0 indicates that the certificate validity is blocked.
// CURLOPT_COOKIE => GetCook ($ url ),

// CURLOPT_USERAGENT => "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)", // simulate the browser used by the user, the HTTP request contains a "user-agent" header string.
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 ";

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.