timmy2 Posted August 6, 2007 Share Posted August 6, 2007 I have 5 pages footer.php, header.php, sidebar.php, login.php and index.php When the page is on login.php I dont want to display the login link however my code's not working Sidebar.php <?php $coologin = 'login.php'; if ($_SERVER['PHP_SELF'] === $coologin) { ?> <?php } else { ?> <h2><a href="#" onclick="toggle_visibility('login');">Login</a></h2> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/63602-solved-getting-the-page-of-output/ Share on other sites More sharing options...
mohaakilla51 Posted August 6, 2007 Share Posted August 6, 2007 you could try to do it a different way... <?php $url = “http://” . $_SERVER[’HTTP_HOST’] . $_SERVER[’PATH_INFO’]; if($url!=//whatever your login URL is) { echo 'whatever your link code is'; } ?> I believe the problem was with your use of PHP_SELF, because it winds up returning sidebar.php... P.S. I got all of this info from <a href='http://www.scriptygoddess.com/archives/2003/01/20/getting-the-current-url-with-php/' target='_blank'>Scripty Goddess</a> from a simple Google Search Link to comment https://forums.phpfreaks.com/topic/63602-solved-getting-the-page-of-output/#findComment-316934 Share on other sites More sharing options...
The Little Guy Posted August 6, 2007 Share Posted August 6, 2007 Like so: <?php function filename($url){ $pos = strrpos($url,'/'); $str = substr($url,$pos+1); return $str; } if(filename($_SERVER['SCRIPT_FILENAME']) != 'login.php'){ echo'<h2><a href="#" onclick="toggle_visibility(\'login\');">Login</a></h2>'; } ?> Link to comment https://forums.phpfreaks.com/topic/63602-solved-getting-the-page-of-output/#findComment-316940 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.