Questions about simulating post data using curl-php Tutorial

Source: Internet
Author: User
Tags form post
The curl simulates post data and simulates login to a page. you can use html to write a form post to log on, but you cannot use curl to log on. What is the problem ------ solution ------------------ your error is only executed once & nbsp; curl_exec ($ ch) according to the current login page design, the user login process is: 1. enter the single-page curl of the table to simulate post data problems
Simulate login to a page, write a form in html and post it to log on, but you cannot log on with curl. What is the situation?


------ Solution --------------------
You only performed curl_exec ($ ch) once during your error)
According to the current login page design, the user login process is:
1. enter the table list page. here, the sessionid has been passed in, or
2. fill in the form and submit
3. verify that the user passes the authentication and then reset the cookie.

You only start from step 2, so CURLOPT_COOKIEJAR only obtains the cookie generated in step 3.
Because the cookie in step 1 is missing, the verification fails.

So you need
1. go to the table list page and use CURLOPT_COOKIEJAR to record the cookie
2. go to the form processing page and pass the cookie saved in step 1 through CURLOPT_COOKIEFILE.

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.