Welcome Guest, Not a member yet? Register   Sign In
How do I display a view after logging in?
#1

[eluser]EthanSP[/eluser]
Why does the forms_menu (my menu items) doesn't show up after I've successfully logged in ($proceed becomes true)?

function index() {
ini_set('display_errors', 'On');
$data['msg'] = ' ';
$this->banner();
$proceed = $this->login();
if ($proceed)
$this->forms_menu();
}
#2

[eluser]Michael Wales[/eluser]
Well, without seeing the code within forms_menu() the only explanation is that $proceed !== TRUE.
#3

[eluser]Gavin Blair[/eluser]
Either $this->login() is returning TRUE (or 1) or forms_menu has a problem that prevents it from displaying anything.
#4

[eluser]EthanSP[/eluser]
Gavin, Mike, & the rest of the community,

Here's the code of my login feature that won't display the menu items after successfully logging in and that's where I need help:

Controller
Code:
<?
class Welcome extends Controller {
    var $proceed;
    function __construct() {
        parent::Controller();
        $this->load->helper('form');
        $this->load->helper('html');
        $this->load->library('Date_library');
        * $this->load->model('bangungot_model');
        $this->proceed = false;
    }
    function index() {
        ini_set('display_errors', 'On');
        $data['msg'] = ' ';
        $this->banner();
        $proceed = $this->login();
        $this->forms_menu($this->proceed);
    }
    function banner() {
        $data = $this->bangungot_model->get_paths();
        $clock = new Date_library;
        $data['digital_clock'] = $clock->show_clock();
        $data['process_title'] = 'Log-in';
        $this->load->view('banner', $data);
    }
    function login() {
        $this->load->model('mdl_login');
        $data['msg'] = '';
        if($this->input->post('submitted')) {
            $this->banner();
            $data['msg'] = $this->mdl_login->check_user(); }
        $data = array_merge($data, $this->bangungot_model->get_paths(), $this->mdl_login->get_fields());
        if ($data['msg'] != 'User found.') {
            $this->load->view('login', $data);
            return false; }
        else { return true; }
    }
    function forms_menu($proceed) {
        if ($proceed) {
            $data = $this->bangungot_model->forms_menu();        
            $this->load->view('forms_menu', $data); }
    }
}
?>

Model
Code:
<?
class Bangungot_model extends Model {
    var $bmenu;
    function __construct() {
        parent::Model();
        $this->bmenu = '';
        $this->load->helper('url');
    }
    function get_titles() {
        $this->load->database();
        $this->db->where('place !=', 'null');
        $this->db->order_by('place');
        $sections = $this->db->get('sections');
        return $sections->result();
    }    
    function forms_menu() {
        $data = $this->get_paths();
        $data['menu_items'] = $this->get_titles();
        $this->load->library('BangungotMenu');
        $bmenu = new BangungotMenu;
        $data['bmenu'] = $bmenu->show_menu($data['menu_items']);
        return $data;
    }
}
?>
Code:
<?
class Mdl_login extends Model {
    var $user_id;
    var $password;
    function Mdl_login() {
        parent::Model();
    }
    function get_fields() {    
        $data['title'] = 'Log-in';
        $data['f_user_id'] = array('name'=>'user_id');
        $data['f_password'] = array('name'=>'password','type'=>'password');
        return $data;
    }    
        function check_user() {
        $this->load->database();
        $this->db->where('user_id', $this->input->post('user_id'));
        $this->db->where('password', $this->input->post('password'));
        $result = $this->db->count_all_results('login');
        if ($result != 0)
            $msg = 'User found.';
        else
            $msg = 'Sorry, but you\'re not registered.';
        return $msg;
    }
}
?>

View
Code:
#login
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
        &lt;head&gt;
            &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
            &lt;title&gt;Bangungot Databank&lt;/title&gt;
            &lt;link rel="SHORTCUT ICON" href="http://192.168.4.235/bangungot/images/bangungot.ico"&gt;
            &lt;link href="&lt;?= $base ?&gt;/&lt;?= $custom_css ?&gt;" rel="stylesheet" type="text/css" /&gt;
            &lt;style type="text/css"&gt;
                #login_box { position: absolute; top: 150px; left: 30%; right: 30%; z-index: 900; }
            &lt;/style&gt;
        &lt;/head&gt;
        &lt;body&gt;
            <div id='login_box'>
              <div class="jwin">
               <div class="jwin1">&lt;?= $title ?&gt;</div>
                &lt;?= form_open('welcome/login'); ?&gt;
               <div class="jwin2">
                  <div class="jmenu">
                       &lt;? $attributes = array('class'=>'jdatacol');
                    $list = array('Your ID:', 'Your Password:');
                      echo ul($list, $attributes); ?&gt;
                   </div>
                  <div class="jmenu">
                     &lt;? $attributes = array('class'=>'jdatacol');
                      $list = array(form_input($f_user_id), form_input($f_password));
                    echo ul($list, $attributes); ?&gt;
                   </div>
                    <div class="jwin3">
                     &lt;? $submit_data = array('name'=>'submitted','value'=>'Log-in','class'=>'jbutton');  
                      echo form_submit($submit_data);
                   echo form_close(); ?&gt;
                 </div>
                    <div class="jwin3" style="color: red">&lt;?= $msg ?&gt;</div>
                  </div>
              </div>
            </div>
        &lt;/body&gt;
    &lt;/html&gt;
Code:
# menu
&lt;body&gt;
   <div id="menu">&lt;?= $bmenu ?&gt;</div>
&lt;/body&gt;




Theme © iAndrew 2016 - Forum software by © MyBB