0

I have the following url

http://www.example.com/check.php?q=498#2D83B631%3800EBD!801600D*7E3CC13

Then I try

<?php var_dump( $_GET); ?>

and

<?php
echo $my_string = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
?>

But they both seem to stop at the "#" symbol and only display 498. Is there a way to retrieve the entire 498#2D83B631%3800EBD!801600D*7E3CC13?

user5095266
  • 119
  • 2
  • 7
  • Yes, because `#` in a URL defines where the `fragment` section begins, ending the query part. You need to encode special characters. – Jonnix May 24 '16 at 11:27

2 Answers2

1

On the server you can get only the url until #. If you want the value after # you need some client side script to get the url.

If that is value of q you should encode first with urlencode(). In this way you will get all the value from q

Your url should look like: http://www.example.com/check.php?q=498%232D83B631%253800EBD!801600D*7E3CC13

To decode the url you can use urldecode()

Daniel Dudas
  • 2,972
  • 3
  • 27
  • 39
0

Fragments are not send to the server at all.

https://en.wikipedia.org/wiki/Fragment_identifier

When an agent (such as a Web browser) requests a web resource from a Web server, > the agent sends the URI to the server, but does not send the fragment.

Passing the data as another GET parameter would be a viable alternative.

Shira
  • 6,392
  • 2
  • 25
  • 27