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