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>
<noframes>&lt;br/&gt; &lt;body&gt;&lt;br/&gt; &lt;/body&gt;&lt;br/&gt;</noframes>