Mysql showing values

Dobby

Member
Nov 8, 2010
156
5
Hello i have a login and register script but when people login in i want it to show what rank they are.

So when a person logs in it will say

Welcome "user"
Your rank is: "Rank"

How would i do this?
 

Dobby

Member
Nov 8, 2010
156
5
The members mage

PHP:
                    <?php
session_start();
require_once("connect.php");
 
// Check his status.
if (!empty($_SESSION[username])) // he got it.
{
   
    echo "You are currently logged in as <b>$_SESSION[username]</b>.<br>";
    echo "Your Pre-Alpha rank is:";
   
   
   
   
   
   
   
   
}
else // bad info.
{
    echo "You are currently <b>NOT</b> logged in.";
}
 
?>


Login
PHP:
<?php
session_start();
// Check if he wants to login:
if (!empty($_POST[username]))
{
    require_once("connect.php");
 
    // Check if he has the right info.
    $query = mysql_query("SELECT * FROM members
                            WHERE username = '$_POST[username]'
                            AND password = '$_POST[password]'")
    or die ("Error - Login failed.");
   
    $row = mysql_fetch_array($query)
    or die ("Error - Login failed.");
   
    if (!empty($row[username])) // he got it.
    {
        $_SESSION[username] = $row[username];
        echo "Welcome $_POST[username]! You've been successfully logged in.<br>";
        echo "right now the UCP is being worked on but you are on the system.<br>";
        exit();
    }
    else // bad info.
    {
        echo "Error - Login failed.<br /><br />
            Please try again.";
        exit();
    }
}
 
?>
 

DaLightz

See ya'll in the afterlife.
May 19, 2012
1,136
262
PHP:
$dbquery = mysql_query("SELECT rank FROM ranktable WHERE username=""$SESSION['username']");
 
Code:
rank is: <?php echo $dbquery ?>
I think.
 

Dobby

Member
Nov 8, 2010
156
5
PHP:
$dbquery = mysql_query("SELECT rank FROM ranktable WHERE username=""$SESSION['username']");
 
Code:
rank is: <?php echo $dbquery ?>
I think.

That wont work? I dunno where you are getting rank table from?

database is
u739026383_beta
inside is the table: members with a colum called: Rank. Default is member
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
change
$dbquery = mysql_query("SELECT rank FROM ranktable WHERE username=""$SESSION['username']");

with
$dbquery = mysql_result("SELECT rank FROM ranktable WHERE username=""$SESSION['username']");
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
change
$dbquery = mysql_result("SELECT rank FROM ranktable WHERE username=""$SESSION['username']");

with
$dbquery = mysql_result("SELECT rank FROM ranktable WHERE username='".$SESSION['username']."');
 

Users who are viewing this thread

Top