Welcome Guest, Not a member yet? Register   Sign In
Displaying session data into view?
#1

[eluser]anna16[/eluser]
Hi guys

I'm trying to display a data in view.

Here is the controller...
Code:
function login_account()
  {
        $this->data['username'] = $this->input->post('username');
        //store data to session.
        $this->session->set_userdata($this->data['username']);        
        
        //set form fields rules
    $this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');
    $this->form_validation->set_rules('username', 'Username', 'callback_username_check2');

        $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
        $this->form_validation->set_rules('password', 'Password', 'callback_password_check2');
        
        if ($this->form_validation->run() == FALSE) //display the login form again if invalid data is encountered.
        {
            $this->load->view('template/login-template', $this->data);            
        }
        else
        {
            $this->load->view('template/memberarea-template', $this->data);
        }
  }

Here is the view.
Code:
<table  bgcolor="#FFFFFF"  cellspacing="6">
<tr><td>

  <fieldset>
    <legend><b>Member Area</b></legend>
        &lt;?php echo "Welcome <b>", $this->session->userdata('username'); echo "</b> "; echo anchor('membership/site/login_form', 'Logout');?&gt;        
        <br><br><br><br><br><br><br><br><br><br>
  </fieldset>  
  
</td></tr>
</table>
<br>
&lt;?php #echo $username; ?&gt;<br>
&lt;?php #echo $password; ?&gt;<br>
<br><br>
&lt;?php echo validation_errors(); ?&gt;

I just really want to display the session username in the view.
But it doesn't display.

Thanks in advanced.


Messages In This Thread
Displaying session data into view? - by El Forum - 12-22-2010, 01:03 AM
Displaying session data into view? - by El Forum - 12-22-2010, 02:00 AM
Displaying session data into view? - by El Forum - 12-23-2010, 01:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB