Skip to content

Instantly share code, notes, and snippets.

@Johndllee
Johndllee / controllers-list.php
Last active August 29, 2015 14:04
mycitest/list/index/10 ->error message 404 Page Not Found
<?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 August 29, 2015 14:03
integrate the simple CRUD and login system
<?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);