0

I can't get the parameter values, if a value in the URL has the character '#'

Say if i want to set the above values to my URL parameters and print them on PHP
client=hello#56
code=123

I'd set the URL like this,
www.blah.com/index.php?client=hello#56&code=123

$client= isset($_GET['client']) ? $_GET['client'] : "" ;
$code= isset($_GET['code']) ? $_GET['code'] : "" ;


echo "This is client : $client <br /> ";
echo "This is code : $code <br />";

The Output will be, '

This is client : HELLO

ONLY, the rest of the parameters dont get displayed.
After doing some testing i noticed that everything after the '#' in the client parameter wont get displayed .
Why is this and how can i overcome this?

Elinoter99
  • 599
  • 1
  • 7
  • 22
  • 2
    Part after `#` is call a fragment and never passed to server by default. You need some javascript to parse it and send to server. Or `urlencode` parameter before adding it to url. – u_mulder Nov 05 '17 at 12:14
  • may be this will help you https://stackoverflow.com/questions/12427431/passing-strings-having-special-characters – Devsi Odedra Nov 05 '17 at 12:16
  • A `#` usually refers to a html elment with an `id` equal to the value that is behind the `#` – SuperDJ Nov 05 '17 at 12:48

1 Answers1

0

from whereever the request to this file is made, urlencode the string before sending it. Sending data without encoding may lead to a lot of problems. For instance,any question mark (?) and equals (=) combination will trigger a new GET variable and the data of actual variable get's lost.

For more on encoding/decoding, see PHP URL Encoding / Decoding

Yash Kumar Verma
  • 9,427
  • 2
  • 17
  • 28