My ios app have to send/retrive some date throught some php pages. This is an example call usingi STHTTPRequest :
__block STHTTPRequest *up = [STHTTPRequest requestWithURLString:[NSString stringWithFormat:@"%@%@",PATHSERVER,@"retrivedata.php"]];
up.encodePOSTDictionary=NO;
up.postDataEncoding=NSUTF8StringEncoding;
up.POSTDictionary = @{@"name":@"Name", @"surname":@"Surname"};
It's all ok until i decide to insert something lik :
up.POSTDictionary = @{@"name":@"Na&me", @"surname":@"Surname"};
In this way a
print_r($_POST);
in retrivedata.php results in:
Array
(
[name] => Na
[surname] => Surname
)
The name is cutted at the "&" char index. I have tried with no success something like:
utf8_encode/utf8_decode($name)
It seems that name arrives to retrivedata.php already cutted, so i can't use any chars conversion/encoding... In my STHTTPRequest i have already tried to set:
up.encodePOSTDictionary=YES;
With this setting i can send "&" as $amp; but if i do a SELECT to retrive the value i can't convert it to the normal string by
html_entity_decode();
it still remain
&
How i can do? My STHTTPRequest send 'Na&me' but it comes blank to $_POST[] in retrivepage.php
I am not really familiar with the shttprequest, but you should url encode it. It will look like "Na%26me" when URL encoded. Later in the post you will have "Na&me"
Hope it helps :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.