MySQL Forums
Forum List  »  PHP

Query Using Session ID
Posted by: Andy Benham
Date: April 02, 2017 01:52PM

Hi all,

Sorry I'm very new to this,

I want to do something I thought would be quite simple, that is I want to pull the users real name (first and last) from my database when they login.

The login system I am using sets up the 'username' as the session ID, which is presented in the php as $_SESSION['user']

Using mySQLi I imagined I could do something like this:



////PHP///

$_SESSSION['username'] = $username;

$result = $db->query("SELECT `firstname`, `lastname` FROM `members` WHERE username='$username'") or die($db->error);

if($result->num_rows){

$rows = $result->fetch_assoc();

}
///

Then pull it from the array and just insert it in to the site header, however I can return this in any permutation I try.

Anybody point to what I'm doing wrong?

Options: ReplyQuote


Subject
Written By
Posted
Query Using Session ID
April 02, 2017 01:52PM
April 02, 2017 01:55PM
April 02, 2017 02:39PM
April 02, 2017 02:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.