johnsmith153 Posted May 9, 2008 Share Posted May 9, 2008 <?php $addressbar = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; echo $addressbar; ?> Is this reliable? I need to grab certain parts of the address bar in my php code. If I can not get the address bar info, my site would hardly work. I have heard how sometimes php cant pick up on this info, but I may be thinking of something else. I am not bothered about security (as I know these things can easily be changed) - if someone wants to prevent it being sent then they just wont see my site - however I want to ensure genuine users are not prevented by no fault of their own. I.e AOL users for example get a weird experience / IP address change etc. Just want to make sure there isn't some sort of thing where address bar info can not be picked up and by no fault of the user. Just a quick YES would be fine if I should go ahead with this. If I see a load of YES posts that is enough for me. Although if not sure, don't post. Thanks. Link to comment https://forums.phpfreaks.com/topic/104857-addressbar-http-_serverserver_name-_serverrequest_uri/ Share on other sites More sharing options...
marklarah Posted May 9, 2008 Share Posted May 9, 2008 that should be ok in most cases, but just to be on the safe side, why dont have you 2 variables, one in your config file somewhere containing "http://www.whatever.com/" and then another on each page before your include containing the name of your file (so eg, login, members") and then you do: $addressbar = $mysite.$page.".php"; EDIT: i use this for a number of reasons. I can track the last page my users visited by inserting $page into the DB, and also you can put it in the title: <title>MySite :: <?=$page?> Link to comment https://forums.phpfreaks.com/topic/104857-addressbar-http-_serverserver_name-_serverrequest_uri/#findComment-536798 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.