Access Pages

4 posts Page 1 of 1
Contributors
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

Access Pages
Mark
Hello,

I use the code below to allow members that have the user level 2 to view the page but is there away so that i can allow people with user level 1 to view the page aswell?
Code: Select all
  <?php

        if($user_level != 2){
            echo "You dont have access to this page sorry!  Please register an account today to support the club <a href='register.php'>Click Here</a>.";
        }
      else {
        
        $select_profile = "select * from team order by rand()";
        
        $run_profile = mysql_query($select_profile);
        
        while($row=mysql_fetch_array($run_profile)){
            $id = $row['id'];
            $fullname = $row['name'];
            $fight_name = $row['fight_name'];
            $age = $row['Age'];
            $height = $row['Height'];
            $weight = $row['Weight'];
            $record = $row['Record'];
            $image= $row['image'];
        ?>
        
       <div id="images">
            <a href="profile.php?id=<?php echo $id; ?>">
            <img src="profile/<?php echo $image;  ?>" width="200" height="200" />
            </a>
       </div>
        
        <?php }} ?>
http://www.mbappz.com
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: Access Pages
CodenStuff
Just woke up but couldn't you just use something like:
Code: Select all
if($user_level >= 1)
dunnno;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

Re: Access Pages
Mark
Hello Codenstuff,

I tried what you said and it didnt work lets everyone view the page

if i put this code

if($user_level != 2)

it lets people with user_level 2 view it but not with people with user_level 1?
http://www.mbappz.com
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

Re: Access Pages
Mark
Hello,

Got that sorted thanks.

One more thing how do i get this in to a table so it displays the records along the way?
Code: Select all
<?php
        
         if( ($user_level != 1) && ($user_level != 2) ){
            echo "You dont have access to this page sorry!  Please register an account today to support the club <a href='register.php'>Click Here</a>.";
        }
        
        else {
        
        $query = "select * from users";
        $run = mysql_query($query);
        while ($row=mysql_fetch_array($run)){
            $username = $row['username'];
        ?>
        
        <?php  
        echo $username ?><br />
        <?php
        }
        }
        ?>
    
http://www.mbappz.com
4 posts Page 1 of 1
Return to “Help & Support”