Normal form login How to change into PHP curl simulation form Login

Source: Internet
Author: User


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.

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