Take the 2-minute tour ×

I need to let my users type anything at the end of my url, like this:




And then I would like to get that last bit that they added to the end of the url like so:

$var = $_POST[''];

But I'm not sure how to go about this, and I can't find anything, because I'm not quite sure how to search for it.

Any help is appreciated, thanks!

share|improve this question
You might want to consider using $_GET. –  weltraumpirat Dec 30 '10 at 17:51
Okay, but how exactly would I accomplish this, when I don't know what the user has entered? –  anon271334 Dec 30 '10 at 17:53
add comment

2 Answers

up vote 1 down vote accepted

With http://mysite.com/?somethingorother you can use:

share|improve this answer
Just using $_SERVER['QUERY_STRING'] would probably be a better idea... –  cdhowie Dec 30 '10 at 17:55
+1 - I will mark as answer when it lets me. Thanks for your help! Btw: I had to change it from 2, to 11 ;) –  anon271334 Dec 30 '10 at 17:58
$_SERVER['QUERY_STRING'] works perfectly. Thank you :) –  anon271334 Dec 30 '10 at 18:03
add comment

For your second example you'd need to use url rewriting (search mod_rewrite) anyway. If there is a ? you can just

foreach($_GET as $key => $value) {   echo "$key: $value"; }
share|improve this answer
add comment

Your Answer

