0

I want to pass param value as 'abc & pqr'. How to get it in php post request.. I tried..

if(isset($_REQUEST["session1"]) && isset($_REQUEST["token"]) && isset($_REQUEST["company"]) ){

    $session1   = $_REQUEST["session1"];
    $token      = $_REQUEST["token"];
    $company    = $_REQUEST["company"]; 

    $result = $session1 ." ". $token ." ". $company;
    echo $result;   
}

I passed param in URL as ?session1=123&token=2&company=Abc & lmn

with Output as : '123 2 Abc ' it displays only Abc . How to get whole company value as 'Abc & lmn'?

Syscall
  • 19,327
  • 10
  • 37
  • 52
TejpalBh
  • 427
  • 4
  • 13
  • Just add the ampersand in the string concatenation? `$result = $session1 ." & ". $token ." & ". $company;` – Can O' Spam May 08 '18 at 12:10
  • 3
    Your just need to urlencode the company name `Abc+%26+Imn` – FMK May 08 '18 at 12:12
  • Right - misunderstood the Q - before page submission, use `urlencode($value)` and the ampersand will come through as `&` – Can O' Spam May 08 '18 at 12:12
  • @FMK how to do that ?? I am passing params from from Android Post request. Can i use Unicode char for & and then pass it to param?? but how to get it back in php? – TejpalBh May 09 '18 at 04:42
  • If the android application would use a POST request you would not have this problem. The android app is using a GET request. For this the app needs to urlencode the data (see https://stackoverflow.com/questions/3286067/url-encoding-in-android ) in order for you to use it correctly in php! – FMK May 09 '18 at 05:50

0 Answers0