Display welcome message

Hi all,
Im a newbie to codeIgniter. I have a login form. And if I successfully login I have to display a welcome message using session variable and also display some basic information from the database on the homepage. How can I achieve it.
Please help.


I think these 2 things will help to accomplish u'r task...

Codeigniter session: http://ellislab.com/codeigniter/user-gui...sions.html
Active Record Class: http://ellislab.com/codeigniter/user-gui...ecord.html

the first function to set flashdata (to do a session variable, like an alert)
the second function to pull some info from the database (from a table called users) and load a new view that should show that data in the variable $database_users (just do a foreach loop and iterate over each item echoing it out)

example welcome controller

class welcome extends controller{
    function welcome(){parent::controller();}

    function index(){
    function flash_me(){
        $this->session->set_flashdata(array('alert'=>'here is an alert! display it by looking for flashdata in the view'));

    function database_users(){
        $data['database_users'] = $this->db->select('*')->from('users')->limit(5)->get()->result_array();

the example view to go with the database query, i put the flash_show() function into a helper for my projects and just call it where i want to show flashdata.

function flash_show()
    $ci = get_instance();
    $alert = $ci->session->flashdata('alert');
        echo '<code>'.$alert.'</code>';

&lt;?php flash_show(); ?&gt;

&lt;?php foreach($database_users as $item){ ?&gt;
    <h1>Showing user #&lt;?=$item['id'];?&gt; in the users table</h1>
    &lt;?=$item['username']?&gt;<br />
    &lt;?=$item['password']?&gt;<br />
&lt;?php } ?&gt;

to go with this make a database table called users with an id, username and password field and make a 5 or 6 rows manually just to get a feel for how its accomplished. i do my queries by method chaining one line but usually people don't do that, they will throw it on multiple lines etc this is just my preference.

Thanks tkyy. Let me check it out.

Thanks again

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.