Welcome Guest, Not a member yet? Register   Sign In
Display user's name through out the site
#1

[eluser]max123[/eluser]
Once the user logged in to the system, I want to display his name taken from the database in each and every page in the web site.

eg: Welcome FirstName LastName

where can i define this.

Thanx
#2

[eluser]JHackamack[/eluser]
For scenarios like this I would have a login function set a session variable of "name" or "username" and just echo that out wherever you want on the page. That would be your best bet since you don't have the query the database each time a page loads.
#3

[eluser]max123[/eluser]
That is true. But the problem is i'm taking only the email address as the session identifier. Name should be taken from the database. If so, how can i do it
#4

[eluser]JHackamack[/eluser]
When the user logs in and you set the email address you also query the database
Code:
$this->db->where('email',$this->input->post('email'));
$user = $this->db->get('users');
$user = $user->row();

$this->session->set_userdata('name',$row->firstName." ".$row->lastName);

something similar to that would query the database based on the email, get a row from the users database and sets the session data to the first and last name.
#5

[eluser]max123[/eluser]
Thanx a lot. I'll try that




Theme © iAndrew 2016 - Forum software by © MyBB