Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Check if user exists Reply To: Check if user exists

#169207
chrisburton
Participant

@traq I’m trying to compare what is in the session to what is in the database. If the UID exists in both, the session and the database, I know that user exists.

Variable for UID in session: $user['uid'].

So the code should be the following?:

db::select( 'users,'1','uid'=>$user['uid'] );

After that check is complete, I guess I could just automatically update the name, link and image of the user even if their profile data is the same. I need to do this because when people change their profile images or usernames, those links are no longer valid. Checking them against each other may just be time wasted. Or should I do that?

Update: the following code echoes out to true:

// Check if user exists
    $exists = db::select('users','1',array('uid'=>$user['uid']));
    if($exists) {
        echo "true";
    } else {
        echo "error!";
    }