Normal form Login How to change to Php Curl Demo form Login

Source: Internet
Author: User
Normal form login How to change into PHP curl simulation form Login



2.php
Header (' content-type:text/html; Charset=utf-8 ');
if ($_post[' loginname ') = = ' Lee ' && $_post[' loginpass '] = = ' 123456 ') {
Header (' location:http://bbs.csdn.net ');
} else {


Ask how this kind of form can be modified into a mock landing I wrote it this way, why not?
Create a new 1.php
Header (' content-type:text/html; Charset=utf-8 ');  
$user = ' Lee '; Login user Name
$pass = ' 123456 '; Login Password
$post _fields = "loginname={$user}&loginpass={$pass}";

curl_setopt ($ch, Curlopt_url, ' http://localhost/2.php ');
curl_setopt ($ch, curlopt_post,1);
curl_setopt ($ch, Curlopt_postfields, $post _fields);

Curl_exec ($ch);
Curl_close ($ch);

------Solution--------------------
EchoCurl_exec ($ch);

In addition your 2.php is jump, and there is no return content.
Change to Echo file_get_contnets (' location:http://bbs.csdn.net '); Give it a try
------Solution--------------------
Header (' location:http://bbs.csdn.net ');
The HTTP header formed
http/1.1 302 Found
date:wed, 09:16:38 GMT
Location:http://bbs.csdn.net
content-length:0
content-type:text/html; Charset=utf-8

You're not following the jump?
curl_setopt ($ch, curlopt_followlocation, true);
------Solution--------------------
Didn't #1 say it?
echo curl_exec ($ch);
How can you not output the results?









<title>CSDN Forum Home-Csdn.net</title>










&lt;noframes&gt;&amp;lt;br/&amp;gt; &amp;lt;body&amp;gt;&amp;lt;br/&amp;gt; &amp;lt;/body&amp;gt;&amp;lt;br/&amp;gt;&lt;/noframes&gt;

  • 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.