For phpget data problems, ask the PC client to post data to the background through crul:
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
PHP Data retrieval code in the background:
$ Oldip = $ _ GET ["oldip"];
$ Newip = $ _ GET ["newip"];
$ Urldata = $ _ GET ["urldata"];
$ Agent = $ _ GET ["agent"];
$ Normal = $ _ GET ["normal"];
$ Error = $ _ GET ["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 );
?>
Only oldip, newip, and urldata data can be obtained in the background, and agent, normal, and error data cannot be obtained. What are the possible reasons? How can this problem be solved?
Thank you very much!
Reply to discussion (solution)
Since it is post, how can we accept it with $ _ GET?
Use $ _ POST!
$ 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 );
?>
After $ _ POST is used, the oldip, newip, urldata, agent, normal, and error variables cannot be received. why?
Thank you!
You put the parameter in the url and passed it. how can you get the data!
$ _ REQUEST
$ _ POST
$ _ GET
All of them are recorded to see where the value is passed
How to write the specific value passing code? Paste it out
Well, you actually pass the value through get.
Because spm = 601 #/
As agreed, # indicates the anchor and will not be passed to the text server.
Therefore, the subsequent content is truncated, so you cannot receive it.
This is not the case when using post to pass values.
Paste your curl code
Obviously, you use the get method.
The parameters passed by get must be converted once using 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
Should be changed
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 /? California % 3 Fspm % 3D601% 23% 2F & agent = Mozilla % 2F4. 0 + % 28 compatible % 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
Thank you for your reply from the xuzuning and fdipzone moderators.
Curl code:
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 ();
After the client uses urlencode for transcoding, does the backend need to be decoded?
Thank you!
Are you C ++ or C #
Is there a function corresponding to php urlencode?
If yes, it will be like url + = csoldip;
Changed to url + = urlencode (csoldip );
After url encoding, php does not need to be decoded.
Oh, forget to write. the client is C ++. I will try it. Thank you!
After urlencode, the agent, normal, and error data still cannot be obtained. However, after setting the urldata value to test, you can receive the data. check whether the length of $ _ GET is limited, if you do not need $ _ GET or $ _ REQUEST, is there any other solution? Thank you!
The get method has a limit of 2 k
So you should use the post method.
Http://www.baidu.com? Wd = c % 2B % 2B + curl + post & ie = UTF-8
After urlencode, the agent, normal, and error data still cannot be obtained. However, after setting the urldata value to test, you can receive the data. check whether the length of $ _ GET is limited, if you do not need $ _ GET or $ _ REQUEST, is there any other solution? Thank you!
$ _ GET has a limit of 2 K. you can use POST instead.
Thanks for the reply from the xuzuning and fdipzone moderators. after the client uses POST, the backend can basically get the data, but it has encountered a new problem. ask again:
PC client vc ++ crul post data to the background:
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
Background PHP code:
Oldip = $ _ POST ['oldip ']; // Result: 61.141.251.21
Newip = $ _ POST ['newip']; // Result: 61.141.251.25
Agent =$ _ POST ['agent']; // Result: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732;. NET4.0C;. NET4.0E)
Normal = $ _ POST ['normal']; // Result: 100
Error = $ _ POST ['error']; // Result: 102
All the above variables can be obtained correctly, but there is a problem with getting urldata.
Urldata = $ _ POST ['urldata']; // what you want to get: http://detail.ju.taobao.com/home.htm? Uastk = 8c3def7900 & userid = 301115 #/
But actually get the content: http://detail.ju.taobao.com/home.htm? Uastk = 8c3def7900, unable to obtain & userid = 301115 #/. it may be a question about & ID division. how can this problem be solved?
You
File_put_contents('test.txt ', print_r ($ _ POST, 1 ));
Paste the content of test.txt
Urlencode is fixed. Thanks again for the help of the two moderators. Thank you!