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}"; $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, ' http://localhost/2.php '); curl_setopt ($ch, curlopt_post,1); curl_setopt ($ch, Curlopt_postfields, $post _fields); curl_setopt ($ch, Curlopt_returntransfer, 1); Curl_exec ($ch); Curl_close ($ch);
Reply to discussion (solution)
echo curl_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
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);
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);
Thanks to the owner's help, I changed it.
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}"; $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, ' http://localhost/2.php '); curl_setopt ($ch, curlopt_post,1); curl_setopt ($ch, Curlopt_postfields, $post _fields); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, curlopt_followlocation,true); curl_exec ($ch); Curl_close ($ch);
2.php
Header (' content-type:text/html; Charset=utf-8 '), if ($_post[' loginname ') = = ' Lee ' && $_post[' loginpass '] = = ' 123456 ') { header (' Location: Http://bbs.csdn.net ');} else { }
Execution of 1.php or blank does not implement jump
Didn't #1 say it?
echo curl_exec ($ch);
How can you not output the results?
CSDN Forum Home-Csdn.net
<br/> <body> <br/> </body> <br/>
Thank you for all your help.