Php-PHPcurl simulates website logon but is stuck on the logon page

Source: Internet
Author: User
In the following code, I have successfully obtained cookies and saved them in the txt file, but cannot jump to the logon page. Ask?]. Phpcurl

In the following code, I have successfully obtained cookies and saved them in the txt file, but cannot jump to the logon page. Ask?

$ Ch = curl_init ();
$ Data = 'Email = & password = & autologin = 0 ';
$ Cookie_file = fopen ($ _ SERVER ['document _ root']. "\ cookies.txt", "w ");

Curl_setopt ($ ch, CURLOPT_URL, "http://www.imooc.com/user/newlogin/from_url/1003 ");
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ _ SERVER ['document _ root']. "\ cookies.txt ");
Curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ _ SERVER ['document _ root']. "\ cookies.txt ");
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data );
Curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 1 );
Curl_exec ($ ch );

Curl_setopt ($ ch, CURLOPT_URL, "http://www.imooc.com/space/index ");
Curl_setopt ($ ch, CURLOPT_POST, 0 );
$ Output = curl_exec ($ ch );
Echo $ output;
Curl_close ($ ch );
?>

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.