Welcome Guest, Not a member yet? Register   Sign In
Help on my login controller script !
#1

[eluser]jigen7[/eluser]
my prob is the cookie how can i get the cookie displaying its value on the next page? i know this is a simple script thx

Code:
<?php

class Admin extends Controller
{
    function Admin()
    {
          parent::Controller();
          $this->load->helper('url');    
          $this->load->helper('form');
          $this->load->helper('cookie');
    }
    
    function index()
    {
          redirect('admin/login');
    }
    
    
    function login()
    {
          $user = @$_POST["username"];
          $passwd = @$_REQUEST["password"];
        
    if($user && $passwd) // if user and password is not empty
    {//1
          $sql = "SELECT * FROM users WHERE username = ? AND password = ?";
         $query = $this->db->query($sql, array($user,$passwd));  

           if ($query->num_rows() > 0)
           {//2
                   foreach ($query->result() as $row)
                   {
                  $user =  $row->username;
                  //echo $row->name;
                  //echo $row->body;
                   }
                
            setcookie('user',$user,0);      # set user id
            redirect('main/show_all');
                  
          
          }//2
          else //Wrong Combination or User not found
          {//3
          $data['prompt'] = "BAD Username & Password Combination";
          
          }//3
    
          $this->load->view('admin_login',$data);
    }//22
    else {   // if user and password is empty  show login page
          $data['prompt'] = "Please Enter User and Password";
          $this->load->view('admin_login',$data);
          
          }
    }//2
  
}//1


?>


Messages In This Thread
Help on my login controller script ! - by El Forum - 02-12-2008, 07:50 AM
Help on my login controller script ! - by El Forum - 02-12-2008, 09:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB