Jump to content

[SOLVED] getting the page of output


timmy2

Recommended Posts

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

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

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>';
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.