Welcome Guest, Not a member yet? Register   Sign In
Cannot modify header information
#1

[eluser]Unknown[/eluser]
Warnaing:
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$user_id

Filename: models/login_model.php

Line Number: 18
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home3/banglacu/public_html/admin/system/libraries/Exceptions.php:166)

Filename: libraries/Session.php

Line Number: 662

controller:

Code:
<?php
class Users extends Controller {
function Users()
  {
   parent::Controller();
  }  
function index()
  {
   $this->login();
  }
        function dashboard()
                {
                    
                }
function login()
  {
         $this->form_validation->set_rules('username','username', 'required|trim|max_langth[50]|xss_clean');
         $this->form_validation->set_rules('password','password', 'required|trim|max_langth[50]|xss_clean');
         if ($this->form_validation->run()== FALSE)
          {
            $this->load->view('login_page');
          }
        else
         {
         $username=$this->input->post('username',TRUE);
         $password=$this->input->post('password',TRUE);
         //$this->load->Model('Login_model');
          $user_id = $this->Login_model->check_login($username,$password);          
            
             if(!$user_id)
                  {
                  $this->session->set_flashdata('login_error',TRUE);
                        
                  }
                 else
                 {
                
                 $this->session->set_userdata(array('logged_in'=> TRUE,'user_id' => $user_id  ));
                 }
   }
}
}?>

[color=green]Model:[/color]

<?php class Login_model extends Model {

  function Login_model()
   {
  
    parent:: Model();
    }
  
  function check_login($username,$password)
   {
      $user = xss_clean($username);
      //$pass = sha1($password);
      
      $qry="SELECT * FROM user WHERE username=? AND password=?";
      $res=$this->db->query($qry,array($user,$password));
      if($res->num_rows()>0)
      {
        return $res->row(0)->user_id;
        
      }
      else
      {
       return FALSE;
      }
   }



}


Messages In This Thread
Cannot modify header information - by El Forum - 11-04-2011, 06:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB