Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    Hey!
    So this is the third time ive come for help in 2 days and i feel bad :L So im more than understanding if people dont want to help me out!

    Ive got this code:
    PHP Code:
    <?
    session_start
    ();
    include (
    "config.php");
    $username $_SESSION['username']; 
    $logged mysql_query("SELECT * FROM `users` WHERE `username`='$username'");
    $logged mysql_fetch_array($logged);
    ?>
    <head>
    <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <?
    if($logged["rank"] != "1") {
        
    // not an admin.
        
    exit("You need to be an administrator to view this feature"); // you can redirect to an error page, include something here, doesn't matter, just exit.
    }
     
    // aha.. they are an admin.. show the content.
     
    include ("menus/anav.php")

    ?>
    Dentafrice helped me with some of it but i went on to play around alot with it and see what i could get out of it!!

    Now it doesnt work for some reason and nothing appears when logged in as rank 1 or any other ranks....

    Can anyone help me!! THANKS

    Edited by ReviewDude (Forum Moderator): Identical threads merged.
    Last edited by ReviewDude; 06-04-2009 at 01:13 PM.
    Back for a while

  2. #2
    Join Date
    Jan 2009
    Posts
    159
    Tokens
    0

    Default

    Quote Originally Posted by Obulus View Post
    Hey!
    So this is the third time ive come for help in 2 days and i feel bad :L So im more than understanding if people dont want to help me out!

    Ive got this code:
    PHP Code:
    <?
    session_start
    ();
    include (
    "config.php");
    $username $_SESSION['username']; 
    $logged mysql_query("SELECT * FROM `users` WHERE `username`='$username'");
    $logged mysql_fetch_array($logged);
    ?>
    <head>
    <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <?
    if($logged["rank"] != "1") {
        
    // not an admin.
        
    exit("You need to be an administrator to view this feature"); // you can redirect to an error page, include something here, doesn't matter, just exit.
    }
     
    // aha.. they are an admin.. show the content.
     
    include ("menus/anav.php")

    ?>
    Dentafrice helped me with some of it but i went on to play around alot with it and see what i could get out of it!!

    Now it doesnt work for some reason and nothing appears when logged in as rank 1 or any other ranks....

    Can anyone help me!! THANKS

    Edited by ReviewDude (Forum Moderator): Identical threads merged.
    I'm pretty sure it's for this reason, although I could be making myself look stupid.

    If they are an admin then it shows the content but the content you're showing is

    "include ("menus/anav.php")" but that doesn't show it it just includes it

    I suggest echoing it for example:

    echo ("contents of menus/anav.php here");

  3. #3
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    tried, didnt work :S
    Lol :L DW ill fix thanks for your help anyway!
    Back for a while

  4. #4
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Try this and tell me what comes up:

    PHP Code:
    <?
    session_start
    ();
    include (
    "config.php");
    $username $_SESSION['username']; 

    echo 
    "Username: {$username}<br />";

    $logged mysql_query("SELECT * FROM `users` WHERE `username`='$username'");
    $logged mysql_fetch_array($logged);

    echo 
    "<pre>";
    print_r($logged);
    echo 
    "</pre>";
    ?>

  5. #5
    Join Date
    Jan 2009
    Posts
    159
    Tokens
    0

    Default

    I think it's because you're defining if they're not admin to not let them in but you're not defining if they're logged in, I would of used something like this, but it's probbably not like you need but it's worth a shot:

    PHP Code:
     <? 
    session_start
    (); 
    include (
    "config.php"); 
    $username $_SESSION['username'];  
    $logged mysql_query("SELECT * FROM `users` WHERE `username`='$username'"); 
    $logged mysql_fetch_array($logged); 
    ?> 
    <head> 
    <link href="style.css" rel="stylesheet" type="text/css" /> 
    </head> 
    <? 
    if($logged["rank"] != "1") { 
        
    // not an admin. 
        
    exit("You need to be an administrator to view this feature"); // you can redirect to an error page, include something here, doesn't matter, just exit. 


    else

    {

    if(
    $logged["rank"] != "admin rank here") { 
        
    // is an admin. 
        
    exit("You're an admin!"); // you can redirect to an error page, include something here, doesn't matter, just exit. 


    echo (
    "the contents of menus/anav.php here"

    }

    ?>
    then again probbably wrong again lol i'm just thinking through of what it could be. There's probbably an error in there, wasn't really paying attention when did it.
    Last edited by Joshh; 06-04-2009 at 04:44 PM.

  6. #6
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    What is with the logic there? You're checking to see if they're not an admin, then you're checking to see if they are not an admin again..?

  7. #7
    Join Date
    Jan 2009
    Posts
    159
    Tokens
    0

    Default

    Quote Originally Posted by Dentafrice View Post
    What is with the logic there? You're checking to see if they're not an admin, then you're checking to see if they are not an admin again..?
    no because

    if($logged["rank"] != "1") {
    // not an admin.
    exit("You need to be an administrator to view this feature"); // you can redirect to an error page, include something here, doesn't matter, just exit.
    }
    checks to see if they're not an admin, but it's not checking to see if they are an admin so I added one to check if they are admin, so if they are admin it displays the anav.php if theyre not it displays the "you're not an admin" message

  8. #8
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Quote Originally Posted by Joshh View Post
    no because



    checks to see if they're not an admin, but it's not checking to see if they are an admin so I added one to check if they are admin, so if they are admin it displays the anav.php if theyre not it displays the "you're not an admin" message
    *Removed*

    This is your code..

    This checks to see if the rank is not 1, which I believe is the administrator rank.

    If rank is not 1 (admin rank) Then display the message. You don't need the else, it exits.. so you don't need to else it.

    PHP Code:
    if($logged["rank"] != "1") { 
        
    // not an admin. 
        
    exit("You need to be an administrator to view this feature"); // you can redirect to an error page, include something here, doesn't matter, just exit. 

    Now why *Removed* are you doing the same thing?

    If rank is not admin rank Then display "You are an admin!" *Removed* You're saying they are an admin when they are not. Plus.. if they are not an admin.. it's not even going to get to this section anyway.

    PHP Code:
    if($logged["rank"] != "admin rank here") { 
        
    // is an admin. 
        
    exit("You're an admin!"); // you can redirect to an error page, include something here, doesn't matter, just exit. 


    echo (
    "the contents of menus/anav.php here"
    *Removed*

    Edited by ReviewDude (Forum Moderator): Please do not insult other forum members, or post rude comments.
    Last edited by ReviewDude; 07-04-2009 at 10:44 AM.

  9. #9
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    SHOCK HORROR

    dentafrices way worked :L Yours didnt xox
    Back for a while

  10. #10
    Join Date
    Jan 2009
    Posts
    159
    Tokens
    0

    Default

    Quote Originally Posted by Dentafrice View Post
    *Removed*

    This is your code..

    This checks to see if the rank is not 1, which I believe is the administrator rank.

    If rank is not 1 (admin rank) Then display the message. You don't need the else, it exits.. so you don't need to else it.

    PHP Code:
    if($logged["rank"] != "1") { 
        
    // not an admin. 
        
    exit("You need to be an administrator to view this feature"); // you can redirect to an error page, include something here, doesn't matter, just exit. 

    Now why *Removed* are you doing the same thing?

    If rank is not admin rank Then display "You are an admin!" *Removed* You're saying they are an admin when they are not. Plus.. if they are not an admin.. it's not even going to get to this section anyway.

    PHP Code:
    if($logged["rank"] != "admin rank here") { 
        
    // is an admin. 
        
    exit("You're an admin!"); // you can redirect to an error page, include something here, doesn't matter, just exit. 


    echo (
    "the contents of menus/anav.php here"
    *Removed*
    I see, I didn't think 1 was the administrator rank. And when I read it earlier I thought it said echo not exit sorry.
    Last edited by ReviewDude; 07-04-2009 at 10:45 AM.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •