smonkcaptain Posted April 4, 2011 Share Posted April 4, 2011 Hey all, How can i get the current URL including any $_POST variables which arent visible? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/232688-how-to-get-current-url/ Share on other sites More sharing options...
nethnet Posted April 4, 2011 Share Posted April 4, 2011 The $_SERVER superglobal contains a lot of useful information about the URL, as well as many other things. Look into the following (all related to the URL): $_SERVER['REQUEST_URI']; $_SERVER['PHP_SELF']; $_SERVER['HTTP_HOST']; $_SERVER['QUERY_STRING']; $_SERVER['SCRIPT_NAME']; As far as $_POST data is concerned, just access it using the $_POST or $_REQUEST superglobals. Quote Link to comment https://forums.phpfreaks.com/topic/232688-how-to-get-current-url/#findComment-1196809 Share on other sites More sharing options...
smonkcaptain Posted April 4, 2011 Author Share Posted April 4, 2011 Thanks for the reply, I will take a look. Maybe i havent specified the question too well; Basically, people use my form to search my photodatabase. I'm using $_POST to send data from the form to the query on the results page. If i was to use $_GET i'd have a rather messy URL after anyone searched.. for example: results.php?aircraft=747&airline=BritishAirways&blah=etc.... Hence choosing to use $_POST because it means whatever the search, the url will always be just search.php. However, When a user clicks on a result, it goes to a new page, and i what to be able to have a 'back' button which then takes them back to the results page with the correct search criteria they have choosen. Is this only possible with $_GET? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/232688-how-to-get-current-url/#findComment-1196811 Share on other sites More sharing options...
nethnet Posted April 4, 2011 Share Posted April 4, 2011 You could use sessions to save the query to be accessed between pages. Quote Link to comment https://forums.phpfreaks.com/topic/232688-how-to-get-current-url/#findComment-1196815 Share on other sites More sharing options...
smonkcaptain Posted April 4, 2011 Author Share Posted April 4, 2011 Thanks, i've managed to do it with sessions Quote Link to comment https://forums.phpfreaks.com/topic/232688-how-to-get-current-url/#findComment-1196854 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.