Jump to content

Help with if statements if possible


ignite

Recommended Posts

if(isset($_COOKIE["usNick"]) && isset($_COOKIE["usPass"]))

{

?>

<ul id="nav">

<li class="active"><a href="index.php">Home</a></li>

<li><a href="viewads.php">View Ads</a></li>

<li><a href="myaccount.php">My Account</a></li>

<li><a href="logout.php">Logout</a></li>

<li><a href="terms.php">TOS</a></li>

<li><a href="advertise.php">Advertise</a></li>

<?php

if(ENABLE_FORUMS=="yes"){

echo"<li><a href='".FORUM_LINK."'>Forum</a></li>";

}

$sql = "SELECT * FROM yob_users WHERE username='$user'"; $result = mysql_query($sql);

$row = mysql_fetch_array($result); 

$is_admin = $row['user_status'];

if($is_admin =="admin"){ echo "<li><a href='/admin'>Admin</a></li>"; 

?>

 

 

I am logged in as Admin, but can not see a link to the admin pannel.

 

If you can help me with this ill be very grateful

Link to comment
Share on other sites

Interestingly that code checks to see if $_COOKIE["usPass"] is set, but doesn't even use it in the query to get the suer data. So, basically anyone could change their cookie to the name of an admin and they would get access to the admin link! (if it worked that is).

 

Assuming you are not getting any errors, your query is either empty or the value in $row['user_status'] is not what you are testing. Passwords should be hashed with a salt

 

What does this display?

if(isset($_COOKIE["usNick"]) && isset($_COOKIE["usPass"]))
{
    echo "      <ul id=\"nav\">\n";
    echo "      <li class=\"active\"><a href=\"index.php\">Home</a></li>\n";
    echo "      <li><a href=\"viewads.php\">View Ads</a></li>\n";
    echo "      <li><a href=\"myaccount.php\">My Account</a></li>\n";
    echo "      <li><a href=\"logout.php\">Logout</a></li>\n";
    echo "      <li><a href=\"terms.php\">TOS</a></li>\n";
    echo "      <li><a href=\"advertise.php\">Advertise</a></li>\n";

    if(ENABLE_FORUMS=="yes")
    {
         echo"<li><a href='".FORUM_LINK."'>Forum</a></li>";
    }

    $sql = "SELECT * FROM yob_users WHERE username='$user'";
    $result = mysql_query($sql) or die(mysql_erro());
    $row = mysql_fetch_array($result);
    $is_admin = $row['user_status'];

//For debugging only
echo '<span style="background-color:#cecece;">$row['user_status'] = ' . $row['user_status'] . '<span>';

    if($is_admin =="admin" && $_COOKIE["usPass"]==$row['usPass'])
    {
        echo "<li><a href='/admin'>Admin</a></li>";
    }
}

Link to comment
Share on other sites

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.