tototororo
tototororo

Reputation: 19

PHP: how to check if SPECIFIC user is logged in

I want to show specific information only to a certain user, and my sql query was supposed to work but it doesn't.

in login.php there is this code:

$_SESSION['username'] = $user;

where it stores the certain user logged in right now.

but when I apply the following:

    $uploaderUsername =$_SESSION['username'];
    $result = mysql_query("SELECT status FROM meeting WHERE status = '$statuscheck' ") or die(mysql_error());
    $uploaderresult = mysql_query("SELECT username FROM meeting WHERE status = '$statuscheck' ") or die(mysql_error());

    if ($result != NULL AND $uploaderUsername = '$uploaderresult') {

it shows the content of the 'if' to every user that is logged in. about status and $statuscheck, it's a variable that exists in only one row and that row has a specific username value - it shouldn't apply to every user.

why does this happen?

Upvotes: 0

Views: 248

Answers (2)

Tim
Tim

Reputation: 783

Why don't you add a WHERE statement to your SQL that checks your username? Something like:

$uploaderresult = mysql_query("SELECT * FROM meeting WHERE status = '$statuscheck' AND username =  '$uploaderUsername'");

I maybe missing something...

Upvotes: 0

Domain
Domain

Reputation: 11808

You have used assignment operator '=' instead of equality operator '=='. Just change it.

Upvotes: 1

Related Questions