in the below code, everything works. However if the user is logged in (where is says html goes here) it wont display anything at all.

<?php 
// Connects to your Database 
mysql_connect('host', "user", "password") or die(mysql_error()); 
mysql_select_db("database") or die(mysql_error()); 

//checks cookies to make sure they are logged in 
if(isset($_COOKIE['ID_']))
{
$email = $_COOKIE['ID_']; 
$pass = $_COOKIE['Key_'];
$check = mysql_query("SELECT * FROM users WHERE username = '$user'")or die(mysql_error());
while($info = mysql_fetch_array( $check )) 
{

//if the cookie has the wrong password, they are taken to the login page 
if ($pass != $info['password']) 
{ echo "<center><a href='index.php'>Invalid Password! Please Click Here to Log In</a></center>"; 
} 

//otherwise they are shown the admin area 
else 
{ 
?>

html goes here

<?php
} 
} 
} 
else 

//if the cookie does not exist, they are taken to the login screen 
{ 
echo "<center><a href='index.php'>You DO Not Have Permission to View this Page! Please Click Here to Log In</a></center>"; 
} 
?>

I don't see anything wrong syntax wise but that doesn't always mean much. I've made some modifications to your code, which should shed some light on what is going on. Replace your code with this, run it and if it doesn't make the issue completely obvious then post the output.

<?php 
error_reporting(E_ALL);
ini_set('display_errors', '1');

    echo __LINE__ . "<br />";
// Connects to your Database 
mysql_connect('host', "user", "password") or die(mysql_error()); 
mysql_select_db("database") or die(mysql_error()); 

//checks cookies to make sure they are logged in 
if(isset($_COOKIE['ID_']))
{
    echo __LINE__ . "<br />";
    $email = $_COOKIE['ID_']; 
    $pass = $_COOKIE['Key_'];
    $check = mysql_query("SELECT * FROM users WHERE username = '$user'")or die(mysql_error());
    while($info = mysql_fetch_array( $check ))  
    {   
    echo __LINE__ . "<br />";

        //if the cookie has the wrong password, they are taken to the login page 
        if ($pass != $info['password']) 
        {   
    echo __LINE__ . "<br />";
            echo "<center><a href='index.php'>Invalid Password! Please Click Here to Log In</a></center>"; 
        }   

        //otherwise they are shown the admin area 
        else 
        {   
    echo __LINE__ . "<br />";
            ?>  

            html goes here

            <?php
        }   
    }   
} 
else 

//if the cookie does not exist, they are taken to the login screen 
{ 
    echo __LINE__ . "<br />";
    echo "<center><a href='index.php'>You DO Not Have Permission to View this Page! Please Click Here to Log In</a></center>"; 
} 
?>

This is what i got

"
5
13

Notice: Undefined variable: user in [urlgoeshere] on line 16
"

try to define $user and assign dummy value

Thank you, i defined $email instead of $user. Sorry its been a long night, lucky i had some fresh eyes to go over my code

good for you..

cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.