Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.