Failed curl simulated login

Source: Internet
Author: User
Curl cannot be successfully simulated. curl is a problem --

$ Cookie_file = dirname (_ FILE _). '/cookie.txt ';
$ Data = 'username = Account & password = password ';
$ Curlobj = curl_init ('http: // passport.sundns.com/index.php? Client_id = sundns ');
Curl_setopt ($ curlobj, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ curlobj, CURLOPT_POST, 1 );
Curl_setopt ($ curlobj, CURLOPT_POSTFIELDS, $ data );
Curl_setopt ($ curlobj, CURLOPT_COOKIEJAR, $ cookie_file );
$ First = curl_exec ($ curlobj );
Curl_close ($ curlobj );


$ Curlobj = curl_init ('http: // www.sundns.com/member.php ');
Curl_setopt ($ curlobj, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ curlobj, CURLOPT_COOKIEFILE, $ cookie_file );
$ Output = curl_exec ($ curlobj );
Curl_close ($ curlobj );
Echo $ output;

Cookie.txt in the directory:
# Netscape HTTP Cookie File
# Http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

# HttpOnly_passport.sundns.com FALSE/FALSE 0 PHPSESSID odjcjs622gmhg5k9b2hu92m047


Mysql error:
Not Found
The requested URL/test/login. php was not found on this server.

I tried to jump to my page but reported an error. why?


Reply to discussion (solution)

I changed the writing method, but it still failed.
$ Curl = curl_init ();
$ Cookie_jar = tempnam ('d:/wamp/www/test', 'cooke ');
Curl_setopt ($ curl, CURLOPT_URL, 'http: // www.nidebook.com/do/login.php'); // login interface
Curl_setopt ($ curl, CURLOPT_POST, 1 );
$ Request = 'username = username & password = password ';
Curl_setopt ($ curl, CURLOPT_POSTFIELDS, $ request );
Curl_setopt ($ curl, CURLOPT_COOKIEJAR, $ cookie_jar );
Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ curl, CURLOPT_HEADER, false );
Curl_exec ($ curl );
Curl_close ($ curl );

$ Curl2 = curl_init ();
Curl_setopt ($ curl2, CURLOPT_URL, 'http: // www.nidebook.com/member/homepage.php'); // Personal Center
Curl_setopt ($ curl2, CURLOPT_HEADER, false );
Curl_setopt ($ curl2, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ curl2, CURLOPT_COOKIEFILE, $ cookie_jar );
$ Content = curl_exec ($ curl2 );
Echo $ content;

After the execution, log on to the user interface and check that the user does not exist. the cookie is suspected to be faulty.

Data in cookies:
# Netscape HTTP Cookie File
# Http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
Www.nidebook.com FALSE/FALSE 1461245580 USR eauxwntm % 090% 091461159180% 09 http % 3A % 2F % 2Fwww.nidebook.com % 2Fdo % 2Flogin. php


Include some form Den values of form.

Include some form Den values of form.



It turned out to be like this. thank you. nobody taught me how to solve the problem.

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.