Curl simulates post transfer parameter issues

Source: Internet
Author: User
Please help me to see, I use the curl function to simulate the transfer of parameters between the page, but after the test found that parameters are always not delivered to the specified page, please help me analyze, My code attached:
Header ("content-type:text/html; Charset=utf-8 ");
Include ("basic-lanconf.php");
echo "--------------------Basic-lan configuration Results-------------------";
echo "-------------------------------------------------------
";
echo "(1). Basic-lan Configuration Test results:
";
$url = "http://192.168.0.1/tomato.cgi";
$head =array ();
$head []= "Authorization:basic". Base64_encode ($admin. ":". $pass);
$curlPost = "Lan_ipaddr= $lan _ipaddr&lan_netmask= $lan _netmask&f_dhcpd_enable= $f _dhcpd_enable".
"&dhcpd_startip= $dhcpd _startip&dchpd_endip= $dchpd _endip&dhcp_lease= $dhcp _lease";
$ch = Curl_init ($url);
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, curlopt_useragent, $_server[' http_user_agent ');
curl_setopt ($ch, curlopt_header,0);
curl_setopt ($ch, curlopt_returntransfer,0);//requires the result to be saved to a string or output to the screen with a parameter of 1 and not returned to the screen
curl_setopt ($ch, Curlopt_httphrader, $head);
curl_setopt ($ch, curlopt_post,1);
curl_setopt ($ch, Curlopt_postfields, $curlPost);
$data =curl_exec ($ch);
Curl_close ($ch);
echo "Data= $data
";
echo "Lan-ipaddr= $lan _ipaddr
";
echo "lan-netmask= $lan _netmask
";
echo "F_dchpd_enable= $f _dhcpd_enable
";
echo "dhcpd_startip= $DHCPD _startip
";
echo "dhcpd_endip= $DHCPD _endip
";
echo "Dhcp_lease= $dhcp _lease
";
?>


Reply to discussion (solution)

$url = "http://192.168.0.1/tomato.cgi";?
Do you know what kind of data he needs to accept?

Start with a PHP program to test

$url = "http://192.168.0.1/tomato.cgi";?
Do you know what kind of data he needs to accept?

Start with a PHP program to test

He is a tomato brush router wrt, it is difficult to change the PHP test, hehe

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