0

I have one url with one code. http://www.example.com/exam.php?id=rteter#443545

Now when I click this URL, the value of the id is rteter, means it returns me only portion of code before #.

I have not sent the link with urlencode so please do not give that solutions. Links are already sent, is they any way by which I can get the full value in my php code?

Martha

Martha
  • 1

3 Answers3

0

The # character indicates the start of the fragment identifier and is handled client side. You need to represent it as %23 if you want it sent to the server.

If you are generating query string parameters programatically in PHP, use the urlencode function.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • ya, but link is already sent without this, so cant do anything now. Anything i can do on page where i receive this code? – Martha Jan 21 '11 at 06:44
  • Find the URL in the markup with JavaScript and rewrite it. The terms "stable door" and "already bolted" come to mind though. – Quentin Jan 21 '11 at 06:45
  • Oh. I'm guessing you might mean "sent in an email" or something. Look to see if there is a `location.hash` in JS, and then redirect. – Quentin Jan 21 '11 at 06:46
  • David link is already sent so user will just click the link. cant do anything now – Martha Jan 21 '11 at 06:48
  • 1
    *When they visit /exam.php?id=rteter* look to see if there is a `location.hash` in JS, and then redirect. – Quentin Jan 21 '11 at 09:05
0

Check out this post on stackoverflow: Can I read the hash portion of the URL on my server-side application (PHP, Ruby, Python, etc.)?

It might cover your question.

Community
  • 1
  • 1
Bjoern
  • 15,934
  • 4
  • 43
  • 48
0

use url quote

http://www.example.com/exam.php?id='rteter%23443545'

http://php.net/manual/en/function.urlencode.php

jargalan
  • 5,006
  • 5
  • 27
  • 36
  • then use parse_url (http://www.php.net/manual/en/function.parse-url.php) to get the fragment part and join it with the id parameter – jargalan Jan 21 '11 at 06:58
  • ps: your idea is wrong actually. take a look at these http://stackoverflow.com/questions/2181290/php-zend-framework-how-to-get-request-uri-fragment-from-request-object http://stackoverflow.com/questions/940905/can-php-read-the-hash-portion-of-the-url – jargalan Jan 21 '11 at 06:59