既然是 post,那么怎么用 $_GET 接受呢?
要用 $_POST !

解决方案 »

  1.   

    <?php
    $oldip=$_POST["oldip"]; 
    $newip=$_POST["newip"];
    $urldata=$_POST["urldata"];
    $agent=$_POST["agent"];
    $normal=$_POST["normal"];
    $error=$_POST["error"];
    file_put_contents(test.txt,$oldip,FILE_APPEND);
    file_put_contents(test.txt,$newip,FILE_APPEND);
    file_put_contents(test.txt,$urldata,FILE_APPEND);
    file_put_contents(test.txt,$agent,FILE_APPEND);
    file_put_contents(test.txt,$normal,FILE_APPEND);
    file_put_contents(test.txt,$error,FILE_APPEND);
    ?>使用$_POST之后,oldip、newip、urldata、agent、normal、error变量的数据都收不到了,这是为什么呢?
    谢谢!
      

  2.   

    你把参数放到 url里面传递了,怎么能获取到数据呢!$_REQUEST
    $_POST
    $_GET
    都 记录下来,看看值在哪传的
      

  3.   

    嗯,你实际是 get 方式传值的
    因为有 spm=601#/
    按约定 # 表示锚点,不会传往 文本服务器
    所以其后的内容被截断了,所以你接收不到而用 post 传值时就不会出现这种情况
    贴出你的 curl 代码
      

  4.   

    明显你是用get方式传递的。get 传递的参数需要用urlencode转一次。http://218.204.14.50/test/?oldip=61.141.251.21&newip=61.141.251.25&urldata=http://detail.ju.taobao.com/home.htm?spm=601#/&agent=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E) &normal=100&error=102应该改为echo 'http://218.204.14.50/test/?oldip='.urlencode('61.141.251.21').'&newip='.urlencode('61.141.251.25').'&urldata='.urlencode('http://detail.ju.taobao.com/home.htm?spm=601#/').'&agent='.urlencode('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E) ').'&normal=100&error=102';
    http://218.204.14.50/test/?oldip=61.141.251.21&newip=61.141.251.25&urldata=http%3A%2F%2Fdetail.ju.taobao.com%2Fhome.htm%3Fspm%3D601%23%2F&agent=Mozilla%2F4.0+%28compatible%3B+MSIE+6.0%3B+Windows+NT+5.1%3B+SV1%3B+QQDownload+732%3B+.NET4.0C%3B+.NET4.0E%29+&normal=100&error=102
      

  5.   

    谢谢xuzuning、fdipzone版主的回复
    curl代码:
    CURL *curl;
    CURLcode res; curl_global_init(CURL_GLOBAL_ALL);
    curl = curl_easy_init();
    if(curl) {
    CString url("http://218.204.14.50/test/?oldip=");
    url += csoldip;
    url += "&newip=";
    url += csnewip;
    url += "&urldata=";
    url += csurldata;
    url += "&agent=";
    url += csagent;
    url += "&normal=";
    url += csnormal;
    url += "&error=";
    url += cserror;

    curl_easy_setopt(curl, CURLOPT_URL, CT2A(url));
    curl_easy_setopt(curl, CURLOPT_HTTPGET);
    res = curl_easy_setopt(curl, CURLOPT_USERAGENT, "tian_test"); 
    res = curl_easy_perform(curl);
    if(CURLE_OK == res)
    return TRUE;
    curl_easy_cleanup(curl);
    }
    curl_global_cleanup();客户端使用urlencode转码之后,后台是不是还要解码?
    谢谢!
      

  6.   

    你这是 C++ 还是 C#
    有对应于 php urlencode 的函数吗?
    如果有,则将 形如 url += csoldip; 的
    改为形如 url += urlencode(csoldip); 的
    url 编码后,php 端无需解码
      

  7.   

    urlencode之后还是获取不到agent、normal、error数据,但将urldata值置为test之后,就可以收到数据了,怀疑是不是$_GET长度有限制,如果不用$_GET、$_REQUEST,还有其它解决方案吗?谢谢!
      

  8.   

    get 方式有 2k 的上限
    所以你这的该用 post 方式
    http://www.baidu.com/s?wd=c%2B%2B+curl+post&ie=utf-8
      

  9.   


    $_GET有2k的限制,改用POST就好了。
      

  10.   

    谢谢xuzuning 、fdipzone版主的回复,客户端改用POST之后,后台基本可以获取到数据了,但遇到了新的问题,再请教一下:
    PC客户端vc ++ crul post数据至后台:
    http://218.204.14.50/test/?oldip=61.141.251.21&newip=61.141.251.25&urldata=http://detail.ju.taobao.com/home.htm?uastk=8c3def7900&userid=301115#/&agent=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E) &normal=100&error=102
    后台PHP代码:
    oldip=$_POST['oldip']; //结果:61.141.251.21
    newip=$_POST['newip']; //结果:61.141.251.25
    agent=$_POST['agent']; //结果:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E)
    normal=$_POST['normal']; //结果:100
    error=$_POST['error']; //结果:102
    以上变量都能正确获取,但urldata获取有问题
    urldata=$$_POST['urldata']; //希望获取的内容:http://detail.ju.taobao.com/home.htm?uastk=8c3def7900&userid=301115#/
    但实际上获取的内容:http://detail.ju.taobao.com/home.htm?uastk=8c3def7900,无法获取&userid=301115#/,可能是&号分割的问题,请问这种情况应该怎么处理?
      

  11.   

    你 
    file_put_contents('test.txt', print_r($_POST,1));
    贴出 test.txt 的内容
      

  12.   

    使用urlencode已解决,再次感谢2位版主的帮助。谢谢!