Skip to content

Instantly share code, notes, and snippets.

@Johndllee
Johndllee / controllers-list.php
Last active Aug 29, 2015
mycitest/list/index/10 ->error message 404 Page Not Found
View controllers-list.php
<?php
class Lists extends CI_Controller {
private $limit = 10;
public function __construct() {
parent::__construct();
if(!$this->session->userdata('logged_in')){
//Set error
$this->session->set_flashdata('need_login', 'Sorry, you need to be logged in to view the List');
redirect('home/index');
@Johndllee
Johndllee / application\controllers\home.php
Last active Aug 29, 2015
integrate the simple CRUD and login system
View application\controllers\home.php
<?php
class Home extends CI_Controller {
public function index(){
if($this->session->userdata('logged_in')){
//Get the logged in users id
$user_id = $this->session->userdata('user_id');
//Get all lists from the model
// $this->load->library('/controllers/person'); to load the library
$data['person'] = $this->Person_model->list_all();
//$data['lists'] = $this->List_model->get_all_lists($user_id);