Page 3 of 3 FirstFirst 123
Results 21 to 24 of 24
  1. #21
    Join Date
    May 2007
    Location
    Nebo, NC, USA
    Posts
    2,517
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Hitman View Post
    Hi Dentafrice!

    I have one problem... I've made a page to see all users, with their info like email etc... It only shows my info, not anybody elses... hmm.

    Code.

    PHP Code:
    <?php
    session_start
    ();
    include 
    'config.php';
    if (
    $_SESSION['logged_user'] == true) {
        
    $query mysql_query("SELECT `level` FROM `users` WHERE `username` = '".$_SESSION['logged_user']."'");

    $rows mysql_fetch_array$query );


    if (
    $rows['level'] == 5) {
        
    $query mysql_query("SELECT * FROM `users`");

    $rows mysql_fetch_array($query2);

    echo 
    "Username: ".$rows['username']."</br></br> Email: ".$rows['email']."</br></br>Join date: ".$rows['date']."</BR></BR>Signature: ".$rows['signature']."";

    } else {
        echo 
    "Don't try and get where you shouldn't be...";
    }
    }
    if (
    $_SESSION['logged_user'] == false) {
        echo 
    "Not logged in. Redirecting... <meta http-equiv=\"REFRESH\" content=\"1;url=./login.php\">";
        }
    ?>
    I can't see anything wrong... I will learn to spot mistakes though
    PHP Code:
     <?php
    session_start
    ();
    include 
    'config.php';
    if (
    $_SESSION['logged_user'] == true) {
        
    $query mysql_query("SELECT `level` FROM `users` WHERE `username` = '".$_SESSION['logged_user']."'");

    $rows mysql_fetch_array$query );


    if (
    $rows['level'] == 5) {
        
    $query mysql_query("SELECT * FROM `users`");

    while(
    $rows mysql_fetch_array($query2)) {

    echo 
    "Username: ".$rows['username']."</br></br> Email: ".$rows['email']."</br></br>Join date: ".$rows['date']."</BR></BR>Signature: ".$rows['signature']."";
    }
    } else {
        echo 
    "Don't try and get where you shouldn't be...";
    }
    }
    if (
    $_SESSION['logged_user'] == false) {
        echo 
    "Not logged in. Redirecting... <meta http-equiv=\"REFRESH\" content=\"1;url=./login.php\">";
        }
    ?>

  2. #22
    Join Date
    Sep 2006
    Location
    Hobart, Australia
    Posts
    593
    Tokens
    0

    Default

    Actually, I think it should be this:

    PHP Code:
     <?php
    session_start
    ();
    include 
    'config.php';
    if (
    $_SESSION['logged_user'] == true) {
        
    $query mysql_query("SELECT `level` FROM `users` WHERE `username` = '".$_SESSION['logged_user']."'");

    $rows mysql_fetch_array$query );


    if (
    $rows['level'] == 5) {
        
    $query mysql_query("SELECT * FROM `users`");

    while(
    $rows mysql_fetch_array($query)) {

    echo 
    "Username: ".$rows['username']."</br></br> Email: ".$rows['email']."</br></br>Join date: ".$rows['date']."</BR></BR>Signature: ".$rows['signature']."";
    }
    } else {
        echo 
    "Don't try and get where you shouldn't be...";
    }
    }
    if (
    $_SESSION['logged_user'] == false) {
        echo 
    "Not logged in. Redirecting... <meta http-equiv=\"REFRESH\" content=\"1;url=./login.php\">";
        }
    ?>

  3. #23
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default

    Thanks guys, I know why query2 is there because I was playing around with the querys.

  4. #24
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Bored. Bored. Bored.

    PHP Code:
    <?php

    session_start
    ();
    include(
    'config.php');

    if (isset(
    $_SESSION['logged_user']))
    {
        
        
    $query_code "SELECT `level` FROM `users` WHERE `username` = '".$_SESSION['logged_user']."'"// Defines the query

        
    $query mysql_query$query_code ) or die("Could not perform SQL Query, error: ".mysql_error()); // Executes the query

        
    $rows mysql_fetch_array$query ) or die("Could not perform SQL Query, error: ".mysql_error()); // Grabs the relevent SQL Data from the query


        
    if($rows['level'] === 5)
        {
            
            
    $query_code "SELECT * FROM `users`"// Defines the query
            
    $query mysql_query$query_code ) or die("Could not perform SQL Query, error: ".mysql_error()); // Executes the query

            
    while($rows mysql_fetch_array($query))
            {

                echo(
    "Username: ".$rows['username']."</br></br> Email: ".$rows['email']."</br></br>Join date: ".$rows['date']."</BR></BR>Signature: ".$rows['signature']);

            }
        
        }
        else
        {
            echo(
    "Don't try and get where you shouldn't be...");
        }
        
    }

    if (!isset(
    $_SESSION['logged_user'])) // Could've been simpler by doing an elseif statement, but whatever.
    {

        echo(
    "Not logged in. Redirecting... <meta http-equiv=\"REFRESH\" content=\"1;url=./login.php\">");

    }

    ?>

Page 3 of 3 FirstFirst 123

Posting Permissions

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