Henri Blog

Study and Share knowledge

Simple CRUD – CodeIgniter

with 242 comments

A couple months ago i have developed PHP application. That’s was the first time (and the only one) i used CodeIgniter. The development itself only took a short period, thanks to helpful plugins and libraries such as excel_reader, jpgraph, dompdf and many more. At this moment, i want to share my humble knowledge in creating simple PHP application.

As the title suggest, we are going to create simple CRUD (Create Read Update Delete) application using CodeIgniter framework. The application that we are going to build is not a complex application (that’s why we call it “simple”) but consists of features such as pagination and simple validation.

Here, i’m using CodeIgniter_1.6.3 and MySql 5. Let’s begin.

  1. Database schema. run this script.
    CREATE DATABASE crud;
    
    USE crud;
    CREATE TABLE tbl_person
    (
      id bigint auto_increment PRIMARY KEY,
      name varchar(50),
      gender char(1),
      dob date
    );
    
    INSERT tbl_person (name,gender,dob) VALUES('henrihnr', 'm', '1985-09-09');
    INSERT tbl_person (name,gender,dob) VALUES('name_001', 'm', '1990-01-01');
    INSERT tbl_person (name,gender,dob) VALUES('name_002', 'f', '2000-01-01');
    INSERT tbl_person (name,gender,dob) VALUES('name_003', 'm', '2000-02-02');
    INSERT tbl_person (name,gender,dob) VALUES('name_005', 'f', '2000-04-04');
  2. Database configuration. file: CodeIgniter\system\application\config\database.php
    $active_group = "default";
    $active_record = TRUE;
    
    $db['default']['hostname'] = "localhost";
    $db['default']['username'] = "root";
    $db['default']['password'] = "";
    $db['default']['database'] = "crud";
    $db['default']['dbdriver'] = "mysql";
  3. Base url configuration. file: CodeIgniter\system\application\config\config.php
    $config['base_url']	= "http://127.0.0.1/CodeIgniter/";
  4. Default controller configuration. file: CodeIgniter\system\application\config\routes.php
    $route['default_controller'] = "person";
  5. Model. create file CodeIgniter\system\application\models\personModel.php. Here we are using active record class.
    class PersonModel extends Model {
    	// table name
    	private $tbl_person= 'tbl_person';
    
    	function Person(){
    		parent::Model();
    	}
    	// get number of persons in database
    	function count_all(){
    		return $this->db->count_all($this->tbl_person);
    	}
    	// get persons with paging
    	function get_paged_list($limit = 10, $offset = 0){
    		$this->db->order_by('id','asc');
    		return $this->db->get($this->tbl_person, $limit, $offset);
    	}
    	// get person by id
    	function get_by_id($id){
    		$this->db->where('id', $id);
    		return $this->db->get($this->tbl_person);
    	}
    	// add new person
    	function save($person){
    		$this->db->insert($this->tbl_person, $person);
    		return $this->db->insert_id();
    	}
    	// update person by id
    	function update($id, $person){
    		$this->db->where('id', $id);
    		$this->db->update($this->tbl_person, $person);
    	}
    	// delete person by id
    	function delete($id){
    		$this->db->where('id', $id);
    		$this->db->delete($this->tbl_person);
    	}
    }
  6. Controller. create file CodeIgniter\system\application\controllers\person.php
    <?php
    class Person extends Controller {
    
    	// num of records per page
    	private $limit = 10;
    	
    	function Person(){
    		parent::Controller();
    		
    		// load library
    		$this->load->library(array('table','validation'));
    		
    		// load helper
    		$this->load->helper('url');
    		
    		// load model
    		$this->load->model('personModel','',TRUE);
    	}
    	
    	function index($offset = 0){
    		// offset
    		$uri_segment = 3;
    		$offset = $this->uri->segment($uri_segment);
    		
    		// load data
    		$persons = $this->personModel->get_paged_list($this->limit, $offset)->result();
    		
    		// generate pagination
    		$this->load->library('pagination');
    		$config['base_url'] = site_url('person/index/');
     		$config['total_rows'] = $this->personModel->count_all();
     		$config['per_page'] = $this->limit;
    		$config['uri_segment'] = $uri_segment;
    		$this->pagination->initialize($config);
    		$data['pagination'] = $this->pagination->create_links();
    		
    		// generate table data
    		$this->load->library('table');
    		$this->table->set_empty("&nbsp;");
    		$this->table->set_heading('No', 'Name', 'Gender', 'Date of Birth (dd-mm-yyyy)', 'Actions');
    		$i = 0 + $offset;
    		foreach ($persons as $person){
    			$this->table->add_row(++$i, $person->name, strtoupper($person->gender)=='M'? 'Male':'Female', date('d-m-Y',strtotime($person->dob)), 
    				anchor('person/view/'.$person->id,'view',array('class'=>'view')).' '.
    				anchor('person/update/'.$person->id,'update',array('class'=>'update')).' '.
    				anchor('person/delete/'.$person->id,'delete',array('class'=>'delete','onclick'=>"return confirm('Are you sure want to delete this person?')"))
    			);
    		}
    		$data['table'] = $this->table->generate();
    		
    		// load view
    		$this->load->view('personList', $data);
    	}
    	
    	function add(){
    		// set validation properties
    		$this->_set_fields();
    		
    		// set common properties
    		$data['title'] = 'Add new person';
    		$data['message'] = '';
    		$data['action'] = site_url('person/addPerson');
    		$data['link_back'] = anchor('person/index/','Back to list of persons',array('class'=>'back'));
    	
    		// load view
    		$this->load->view('personEdit', $data);
    	}
    	
    	function addPerson(){
    		// set common properties
    		$data['title'] = 'Add new person';
    		$data['action'] = site_url('person/addPerson');
    		$data['link_back'] = anchor('person/index/','Back to list of persons',array('class'=>'back'));
    		
    		// set validation properties
    		$this->_set_fields();
    		$this->_set_rules();
    		
    		// run validation
    		if ($this->validation->run() == FALSE){
    			$data['message'] = '';
    		}else{
    			// save data
    			$person = array('name' => $this->input->post('name'),
    							'gender' => $this->input->post('gender'),
    							'dob' => date('Y-m-d', strtotime($this->input->post('dob'))));
    			$id = $this->personModel->save($person);
    			
    			// set form input name="id"
    			$this->validation->id = $id;
    			
    			// set user message
    			$data['message'] = '<div class="success">add new person success</div>';
    		}
    		
    		// load view
    		$this->load->view('personEdit', $data);
    	}
    	
    	function view($id){
    		// set common properties
    		$data['title'] = 'Person Details';
    		$data['link_back'] = anchor('person/index/','Back to list of persons',array('class'=>'back'));
    		
    		// get person details
    		$data['person'] = $this->personModel->get_by_id($id)->row();
    		
    		// load view
    		$this->load->view('personView', $data);
    	}
    	
    	function update($id){
    		// set validation properties
    		$this->_set_fields();
    		
    		// prefill form values
    		$person = $this->personModel->get_by_id($id)->row();
    		$this->validation->id = $id;
    		$this->validation->name = $person->name;
    		$_POST['gender'] = strtoupper($person->gender);
    		$this->validation->dob = date('d-m-Y',strtotime($person->dob));
    		
    		// set common properties
    		$data['title'] = 'Update person';
    		$data['message'] = '';
    		$data['action'] = site_url('person/updatePerson');
    		$data['link_back'] = anchor('person/index/','Back to list of persons',array('class'=>'back'));
    	
    		// load view
    		$this->load->view('personEdit', $data);
    	}
    	
    	function updatePerson(){
    		// set common properties
    		$data['title'] = 'Update person';
    		$data['action'] = site_url('person/updatePerson');
    		$data['link_back'] = anchor('person/index/','Back to list of persons',array('class'=>'back'));
    		
    		// set validation properties
    		$this->_set_fields();
    		$this->_set_rules();
    		
    		// run validation
    		if ($this->validation->run() == FALSE){
    			$data['message'] = '';
    		}else{
    			// save data
    			$id = $this->input->post('id');
    			$person = array('name' => $this->input->post('name'),
    							'gender' => $this->input->post('gender'),
    							'dob' => date('Y-m-d', strtotime($this->input->post('dob'))));
    			$this->personModel->update($id,$person);
    			
    			// set user message
    			$data['message'] = '<div class="success">update person success</div>';
    		}
    		
    		// load view
    		$this->load->view('personEdit', $data);
    	}
    	
    	function delete($id){
    		// delete person
    		$this->personModel->delete($id);
    		
    		// redirect to person list page
    		redirect('person/index/','refresh');
    	}
    	
    	// validation fields
    	function _set_fields(){
    		$fields['id'] = 'id';
    		$fields['name'] = 'name';
    		$fields['gender'] = 'gender';
    		$fields['dob'] = 'dob';
    		
    		$this->validation->set_fields($fields);
    	}
    	
    	// validation rules
    	function _set_rules(){
    		$rules['name'] = 'trim|required';
    		$rules['gender'] = 'trim|required';
    		$rules['dob'] = 'trim|required|callback_valid_date';
    		
    		$this->validation->set_rules($rules);
    		
    		$this->validation->set_message('required', '* required');
    		$this->validation->set_message('isset', '* required');
    		$this->validation->set_error_delimiters('<p class="error">', '</p>');
    	}
    	
    	// date_validation callback
    	function valid_date($str)
    	{
    		if(!ereg("^(0[1-9]|1[0-9]|2[0-9]|3[01])-(0[1-9]|1[012])-([0-9]{4})$", $str))
    		{
    			$this->validation->set_message('valid_date', 'date format is not valid. dd-mm-yyyy');
    			return false;
    		}
    		else
    		{
    			return true;
    		}
    	}
    }
    ?>
  7. View. create 3 files at CodeIgniter\system\application\views folder. personList.php to list persons with pagination
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
    <title>SIMPLE CRUD APPLICATION</title>
    
    <link href="<?php echo base_url(); ?>style/style.css" rel="stylesheet" type="text/css" />
    
    </head>
    <body>
    	<div class="content">
    		<h1>Simple CRUD Application</h1>
    		<div class="paging"><?php echo $pagination; ?></div>
    		<div class="data"><?php echo $table; ?></div>
    		<br />
    		<?php echo anchor('person/add/','add new data',array('class'=>'add')); ?>
    	</div>
    </body>
    </html>

    personEdit.php to add or update a person

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
    <title>SIMPLE CRUD APPLICATION</title>
    
    <link href="<?php echo base_url(); ?>style/style.css" rel="stylesheet" type="text/css" />
    
    <link href="<?php echo base_url(); ?>style/calendar.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<?php echo base_url(); ?>script/calendar.js"></script>
    
    </head>
    <body>
    	<div class="content">
    		<h1><?php echo $title; ?></h1>
    		<?php echo $message; ?>
    		<form method="post" action="<?php echo $action; ?>">
    		<div class="data">
    		<table>
    			<tr>
    				<td width="30%">ID</td>
    				<td><input type="text" name="id" disabled="disable" class="text" value="<?php echo $this->validation->id; ?>"/></td>
    				<input type="hidden" name="id" value="<?php echo $this->validation->id; ?>"/>
    			</tr>
    			<tr>
    				<td valign="top">Name<span style="color:red;">*</span></td>
    				<td><input type="text" name="name" class="text" value="<?php echo $this->validation->name; ?>"/>
    				<?php echo $this->validation->name_error; ?></td>
    			</tr>
    			<tr>
    				<td valign="top">Gender<span style="color:red;">*</span></td>
    				<td><input type="radio" name="gender" value="M" <?php echo $this->validation->set_radio('gender', 'M'); ?>/> M
    					<input type="radio" name="gender" value="F" <?php echo $this->validation->set_radio('gender', 'F'); ?>/> F
    					<?php echo $this->validation->gender_error; ?></td>
    			</tr>
    			<tr>
    				<td valign="top">Date of birth (dd-mm-yyyy)<span style="color:red;">*</span></td>
    				<td><input type="text" name="dob" onclick="displayDatePicker('dob');" class="text" value="<?php echo $this->validation->dob; ?>"/>
    				<a href="javascript:void(0);" onclick="displayDatePicker('dob');"><img src="<?php echo base_url(); ?>style/images/calendar.png" alt="calendar" border="0"></a>
    				<?php echo $this->validation->dob_error; ?></td>
    			</tr>
    			<tr>
    				<td>&nbsp;</td>
    				<td><input type="submit" value="Save"/></td>
    			</tr>
    		</table>
    		</div>
    		</form>
    		<br />
    		<?php echo $link_back; ?>
    	</div>
    </body>
    </html>

    personView.php to view a person details

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
    <title>SIMPLE CRUD APPLICATION</title>
    
    <link href="<?php echo base_url(); ?>style/style.css" rel="stylesheet" type="text/css" />
    
    </head>
    <body>
    	<div class="content">
    		<h1><?php echo $title; ?></h1>
    		<div class="data">
    		<table>
    			<tr>
    				<td width="30%">ID</td>
    				<td><?php echo $person->id; ?></td>
    			</tr>
    			<tr>
    				<td valign="top">Name</td>
    				<td><?php echo $person->name; ?></td>
    			</tr>
    			<tr>
    				<td valign="top">Gender</td>
    				<td><?php echo strtoupper($person->gender)=='M'? 'Male':'Female' ; ?></td>
    			</tr>
    			<tr>
    				<td valign="top">Date of birth (dd-mm-yyyy)</td>
    				<td><?php echo date('d-m-Y',strtotime($person->dob)); ?></td>
    			</tr>
    		</table>
    		</div>
    		<br />
    		<?php echo $link_back; ?>
    	</div>
    </body>
    </html>
  8. Style. put stylesheet at CodeIgniter\style\style.css and style’s images at CodeIgniter\style\images folder

    body {
    	font-family:tahoma;
    	padding:0px;
    	margin:0px;
    	background:#f5f5f5
    }
    
    div.content {
    	padding:10px 20px;
    }
    div.content h1 {
    	font-size:18pt;
    	border-bottom:5px solid #a00;
    	padding:0px;
    	margin:10px 0px 20px;
    	width:80%;
    }
    
    div.content div.data table {
    	border:2px solid #000;
    	background:#fff;
    	width:80%;
    }
    div.content div.data table td {
    	font-size:10pt;
    	padding:5px 10px;
    	border-bottom:1px solid #ddd;
    	text-align: left;
    }
    div.content div.data table th {
    	text-align: left;
    	font-size: 8pt;
    	padding: 10px 10px 7px;
    	text-transform: uppercase;
    	color: #fff;
    	background:url(images/head.gif) left -5px repeat-x;
    }
    
    div.paging {
    	font-size: 9pt;
    	margin:5px 0px;
    }
    div.paging a {
    	color:#900;
    	text-transform: uppercase;
    	text-decoration: none;
    }
    div.paging a:hover {
    	color:#c00;
    }
    div.paging b {
    	color:#900;
    }
    
    div.success {
    	font-size:14pt;
    	background:url(images/accept.png) left 5px no-repeat;
    	padding:0px;
    	padding-left:20px;
    	margin:0px 0px 10px;
    	color:#060;
    	width:80%;
    }
    
    a.update, a.delete, a.add, a.view, a.back {
    	font-size: 9pt;
    	color:#900;
    	font-wight:bold;
    	padding-left:20px;
    	text-decoration: none;
    }
    a.update {
    	background:url(images/update.png) left center no-repeat;
    }
    a.delete {
    	background:url(images/delete.png) left center no-repeat;
    }
    a.add {
    	background:url(images/add.png) left center no-repeat;
    }
    a.view {
    	background:url(images/view.png) left center no-repeat;
    }
    a.back {
    	background:url(images/prev.gif) left center no-repeat;
    }
    a.update:hover, a.delete:hover, a.add:hover, a.view:hover {
    	color:#000;
    }
    
    input.text {
    	border:2px solid #aaa;
    }
    
    .error {
    	background: #FBE6F2 none repeat scroll 0 0;
    	border: 1px solid #D893A1;
    	color: #333333;
    	margin: 5px 0 0;
    	padding: 5px;
    	font-size: 10px;
    	font-family: Lucida Grande,Verdana,Geneva,Sans-serif;
    }
  9. Script. put script at CodeIgniter\script folder
  10. Done. Lets preview what should we have by now.
list_of_person

List of persons with pagination

add_new_person

Add new person

update_person

Update person

view_person

View person details

error_validation

Error on validation

Download Simple CRUD Application. Happy Programming!!

Written by Henri H.

April 26, 2009 at 12:21 am

Posted in PHP

Tagged with

242 Responses

Subscribe to comments with RSS.

  1. Hen … pala gua nyut2an ngeliatnya xD

    lunniey

    April 26, 2009 at 9:35 pm

  2. This is hot. This is exactly what I was looking for. Thanks!

    Aalaap Ghag

    May 8, 2009 at 8:47 pm

  3. hoho…great and good job my bro…
    i will try it…!!

    Santen

    May 24, 2009 at 11:10 am

  4. Thanks Bro, You save my life 🙂
    Good Job

    awan pribadi

    May 25, 2009 at 1:12 pm

  5. great tutorial great job, if the admin panel is also integrates then it’s a miracleous job
    thanks

    netvision

    May 30, 2009 at 4:54 pm

  6. Nice tutorial, when i started with codeigniter this is the tutorial that really helped me in expediting the project great job

    dharendera

    May 30, 2009 at 5:06 pm

  7. Thank You, God Bless You.
    Excellent Job.

    Alex Inoa

    July 16, 2009 at 4:59 am

  8. Thank you! [This should really be in the CI documentation.]

    q

    July 27, 2009 at 8:13 am

  9. Awesome brother, super cool

    Anuradha

    August 13, 2009 at 12:31 am

  10. I just posted on my blog a simple CRUD example with pagination and validation using CodeIgniter 1.7.1.
    My example uses this one as base, which I consider a very good example for those who are starting.

    Robertson Freitas

    August 24, 2009 at 12:39 pm

  11. thax a lot man.I got exactly whr i want.

    kabir

    August 27, 2009 at 1:50 pm

  12. Great Job!

    Just the article i needed to read to understand CI a little bit more. I just have a probleme with the redirect in the delete-function. Just see an empty page (maybe header already sent?). Wouldn’t $this->index() do the same?

    Many thanks
    Dirk

    Dirk

    August 29, 2009 at 12:27 am

  13. Mantap nich! Udah mendukung CRUD. Saya suka. Trim’s

    Nonpyrogenic

    September 11, 2009 at 10:03 pm

  14. […] (que está mais para um Active Record Layer), incrivelmente reusável, foi inspirado no copiado do exemplo de CRUD que mencionei acima. Controller gordo + Model magro é considerado um anti-pattern, mas eu gosto […]

  15. Thanks a lot. I was searching internet for a crud in ci. And this one serve my purpose very well. Thanks again.

    Azraf

    September 22, 2009 at 11:05 am

  16. wah..keren gw lagi perlu banget nih,,

    thank you very much..

    Tio

    October 2, 2009 at 10:41 am

  17. What a beautiful piece of work this is: useful, beautifully presented, and a fabulous base for anyone to build on, especially since you went beyond the usual text examples and included things like radio buttons and dates. Really really nice — thank you, Henri.

    Helen

    October 3, 2009 at 9:04 pm

  18. outstanding!!!!!!

    acatejr

    October 25, 2009 at 5:17 am

  19. This is awesome! Easily the best getting started tutorial on CodeIgniter. Thanks!

    Bill

    October 28, 2009 at 10:48 am

  20. Very nice job, very clean code, view is even better than on official examples.
    All the best!

    Frank

    November 6, 2009 at 5:20 am

  21. Back to the code, on linux shall be careful with naming the model. personModel.php is creating a problems, it is not loaded properly on linux.
    Instead, the name shall be personmodel.php.
    The class within the model shall be as it is on the example.
    Best regards,

    Frank

    December 1, 2009 at 2:07 am

  22. Morning,

    Very interesting tutorial. I have bookmarked it so I can spend some time on it later.

    Jez D

    Jez D

    December 21, 2009 at 5:18 pm

  23. awesome job but I did have issues at first where the files were camelCased and this broke it. I just changed to no_camel_case and it worked.

    CHeers

    Boris Badenov

    January 27, 2010 at 12:36 pm

  24. Thanks a lot. I was searching internet for a crud in ci. And this one serve my purpose very well. Thanks again.

    Copirait

    February 1, 2010 at 12:44 am

  25. thx a lot bro ..

    ulrich

    February 5, 2010 at 8:24 am

  26. Thank you for sharing. Very helpful indeed 🙂

    Chris

    February 15, 2010 at 1:24 pm

  27. outstanding!!!!!!!!!!
    thanks

    Rups

    February 17, 2010 at 4:43 pm

  28. u have code for friend request ?

    pari

    February 17, 2010 at 5:04 pm

  29. thank u

    abc

    February 17, 2010 at 5:33 pm

  30. Damn Cool!!!…
    Thank you so much….

    seno

    February 25, 2010 at 2:07 pm

  31. ijin nyimak..
    mau belajar..

    nice info, keep posting 😀

    bluemeda

    February 26, 2010 at 10:29 am

  32. keren… minta ijin untuk mempelajarinya.. =)

    dudu

    February 28, 2010 at 6:27 pm

  33. awesome

    kodegeek

    March 6, 2010 at 1:12 pm

  34. Amazing, thank you, will try learning CI with this

    JREAM

    March 14, 2010 at 3:40 pm

  35. Sorry brow.
    Codenya gak jalan sewaktu add/update/delete. Css-nya juga gak ke load.

    :D…Any suggest?

    Andri Rahmansyah

    March 25, 2010 at 12:58 am

  36. @Andri
    ga jalan yg dimaksud ntu sperti apa??
    error message, log-nya??

    Henri H.

    March 26, 2010 at 4:47 pm

  37. thank you!!!! it helped me a lot…

    techgal

    March 31, 2010 at 1:32 pm

  38. thanks banget bro, sangat membantu saya yang baru belajar CI

    gimana fungsi callback untuk mengecek apakah data sudah ada di dalam database?

    mqa

    April 1, 2010 at 10:16 pm

  39. Nice, tutorial, I don’t see the styling, and only the 1st page comes up with deprecated errors. any thoughts?

    learning

    April 13, 2010 at 10:56 am

  40. Hi ,
    great work , thanks alot . I used it for my last project . Thanks alot man , I owe you one and greetings from IRAN

    Majid

    April 17, 2010 at 12:20 am

  41. thank you so much, it so helpfull! God bless you 🙂

    ar

    April 29, 2010 at 7:50 am

  42. Thanks for a great demo.

    I’m new to PHP and CI.

    Item 5 personModel.php is missing php tags.

    I had problems with this version of CI php 5.3
    until I used the 2 fixes in
    https://henrihnr.wordpress.com/2009/04/26/simple-crud-application/

    John

    May 2, 2010 at 6:05 am

  43. John

    May 2, 2010 at 6:06 am

  44. IF you have the error, “An Error Was Encountered Unable to locate the model you have specified: personModel” when you put this on a live server you can just change the model name to something like Person_M and the function to person_M. There is something weird with having model in the name when on a live server. Don’t know why.

    Kyle

    May 7, 2010 at 4:57 am

  45. Very nicely explained tutorial. But while editing or adding a new person there is this message.

    A PHP Error was encountered

    Severity: 8192

    Message: Function ereg() is deprecated

    Filename: controllers/person.php

    Line Number: 199

    We can replace ereg() with preg_match() for warning to disappear as follows.

    file CodeIgniter\system\application\controllers\person.php

    function valid_date($str)
    {

    if(!preg_match(“(^(0[1-9]|1[0-9]|2[0-9]|3[01])-(0[1-9]|1[012])-([0-9]{4})$)”, $str))

    {
    $this->validation->set_message(‘valid_date’, ‘date format is not valid. dd-mm-yyyy’);
    return false;
    }
    else
    {
    return true;
    }
    }

    Tejas Sali

    May 7, 2010 at 1:54 pm

  46. its a freaking awesome!

    El John

    May 18, 2010 at 9:45 am

  47. Hi Henry
    Thanks for the CRUD Application, It worked and great job you have done. Appreciate.

    I want to add filters such as search by name, sex, department and Unique ID number such as QW23. How Could achieve the filters part, Could you please help for any pointer.

    In addition to this, I wish to add a photograph field and make it work.

    Your help would be highly appreciated.
    Samuel

    Samuel

    June 27, 2010 at 11:23 am

  48. […] create, read, update and delete records (CRUD) I searched for CodeIgniter libraries. I came across this post by Henri. His solution is very simple and easy to understand and implement. In this post I’ll […]

  49. Hi Samuel,
    You’re welcome.

    You can add filter part using request parameter and use it in the query.
    e.g. EXACT MATCH
    1. create search option

    2. get value at Controller
    $id = $this->input->post(‘id’);

    3. use as query condition
    $this->db->where(‘id’, $id);
    return $this->db->get(‘table_name’);

    you can build advance search criteria using combination of any field and search method (LIKE, EXACT MATCH, START FROM, etc).

    To add a photograph field, you can use multipart form provided by CodeIgniter and save as binary object (BLOB) to database.
    e.g.
    1. create upload form at .html

    2. get data at Controller
    $photo = $this->upload->data();

    3. save to database
    INSERT INTO table (photo) VALUES (‘{$photo}’)

    Henri H.

    June 28, 2010 at 2:58 pm

  50. Hi Henri,
    First of All, Thank you so much for your heart to help and response too. You have explained in so understanding and easy way, Many thanks for this, I have not worked though on filter part. I am trying to upload picture but that’s not going success for me. Plz help.

    I have added extra one field in your controller and similarly added that field in personEdit.php, while add new record form displays like

    – Name*
    – Gender*
    – Photo*
    – Date of birth (dd-mm-yyyy)*

    similarly have placed those fields in personEdit.php view file.

    PROBLEM is:
    if I set form parameter on personEdit.php this way
    <form method="post" action="”>
    It does not upload picture but keeps name of that picture(DSCI0117-copy.jpg) table_person’s field called userfile. Rest of other fields are populated properly.

    BUT,
    If I set form parameter
    <form method="post" action="” enctype=”multipart/form-data”>, It actually uploads picture in uploads folder but none of the data is inserted to table called tbl_person.

    Will you please guide me to solve this problem?
    Thank you once again.

    Samuel

    June 30, 2010 at 1:54 am

  51. Sorry, I forgot to mention….
    While setting form parameter this way,
    <form method="post" action="action="” enctype=”multipart/form-data”>

    It uploads picture in upload folder WITH ERROR saying field required on PHOTO but none of the data is inserted to table called tbl_person

    Thank you.

    Samuel

    June 30, 2010 at 2:03 am

  52. first of all, thank you for this post.

    one last question here. any table manipulation need table sort. do you have any idea about table sorting?

    khangai

    June 30, 2010 at 6:19 pm

  53. Hi Henri,
    It seems working now. It actually did not get post value from $this->input->post(‘userfile’)[don’t know the exact reason, why?]; but as it is assinged according as below

    $this->upload->do_upload();
    $this->upload->data();
    $image_data=$this->upload->data();
    $userfile=$image_data[‘file_name’];// <—-this line helped n seems to work now. BUT Thank you for your generous heart and help and obviously CRUD developed, appreciate you, wonderful work. Your guide and above response really helped to solve problem eg searching stuffs and uploading image stuffs. Many thanks.

    By the way, I wish to ask a question, plz answer if you get time, as search results appear, I tried to display to list result page as it is displayed in listing the table data formatting. I want to display results according to that way. Will you please point me?

    Thank you once again.
    Samuel

    Samuel

    July 5, 2010 at 3:46 pm

  54. Cool!!!

    Prantoor

    July 8, 2010 at 5:46 pm

  55. mantap bro

    Joe

    August 7, 2010 at 9:37 pm

  56. Thank’s my friend! Its great tutorial!!!

    Fabio

    August 9, 2010 at 7:26 am

  57. with ruby on rails you would not have to write all this crap!, 1 plugin for pagination, 2 shell commands to generate db, and mvc files and some custom code for validation.

    tomas

    September 5, 2010 at 3:56 am

  58. Thanks a lot 🙂

    Ei Chaw San

    September 20, 2010 at 1:32 pm

  59. Very helpful, great job
    thank a lot bro

    Ibon

    October 9, 2010 at 12:50 pm

  60. makasih mas. your example works better than the one given by my lecturer 😛

    I really appreciate your tuts and you do have a knack for clear concise instructions.

    Thanks a million.

    jlo

    October 24, 2010 at 7:59 am

  61. mas error nih bisa bantuin gak

    A PHP Error was encountered

    Severity: 8192

    Message: Function set_magic_quotes_runtime() is deprecated

    Filename: codeigniter/CodeIgniter.php

    Line Number: 60
    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: libraries/Loader.php

    Line Number: 248
    An Error Was Encountered

    Unable to locate the model you have specified: personmodel

    ion

    November 2, 2010 at 9:10 am

  62. I could use your sample project for my academic purpose. Thank you very much.

    Programmer's Forum

    November 7, 2010 at 1:18 pm

  63. Thank you very much for this excellent codeigniter CRUD tutorial!
    It helps me a lot! 🙂

    Nicholas

    November 8, 2010 at 12:54 am

  64. Terima kasih ya. Tulisan ini sangat membantu aku.

    ciburuan

    November 11, 2010 at 9:05 am

  65. Thank you for posting this great article,,,
    I have one question, if i want to upload image in personEdit form, how can i do it ?

    PS: sorry for my english

    ryan

    November 11, 2010 at 12:47 pm

  66. There is error at line:-226 $CI = new $class(); in CodeIgniter\system\application\controllers\CodeIgniter.php—
    error is

    An Error Was Encountered

    Unable to locate the model you have specified: personmodel

    Atish

    November 11, 2010 at 1:48 pm

  67. Ini gimana ya, kalau di db ada 10 tapi yg tampil cuma 9 ga ada link pagination,
    kalau di db ada 11 halaman pertama tampil 9 ada link ” 1 2 > ” tapi di page 2 nomer (di kolom NO) langsung loncat 11 12 ?

    Apa header tabelnya ikut keitung gt?

    Makasih.

    nafri

    November 19, 2010 at 4:27 pm

  68. halooo sir..i hAVE Any pRobleM About Link in pagination, view, update, delete..
    if I Click link [pagination 1,2 >],view, update n delete can’t link to next page, or new page (View page,update page) and error masagge “The URI you submitted has disallowed characters”
    please help me sir….
    tar klo berhazil tak traktir sate ayam ponorogo…ok

    best regards,
    Addin top markotop.

    Addin Choirudin

    January 26, 2011 at 11:02 pm

  69. @ion
    km pake php versi berapa?cm km ganti pake codeigniter versi 1.7.2

    yoky

    March 10, 2011 at 9:02 am

  70. Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\htdocs\CodeIgniter\system\codeigniter\Common.php on line 123

    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\htdocs\CodeIgniter\system\codeigniter\Common.php on line 129
    A PHP Error was encountered

    Severity: 8192

    Message: Function set_magic_quotes_runtime() is deprecated

    Filename: codeigniter/CodeIgniter.php

    Line Number: 60
    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: libraries/Loader.php

    Line Number: 248
    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: database/DB.php

    Line Number: 133

    Henri H help me ??

    yamasoka

    March 28, 2011 at 6:42 pm

  71. hi mas henry.
    mas klo sms gateway bisa ga menggunakan codeigniter?? terus cara merubah dari php biasa ke codeigniter???
    Makasih mas.. 🙂

    aung

    March 29, 2011 at 9:01 am

  72. you’re henry d’ great

    thanks for your generosity in sharing your knowledge..its really a big help to many..

    mariz cruz

    March 30, 2011 at 10:18 am

  73. To Yamasoka and others who might have experienced the problem on deprecating thing, have a look at this link, it solves the problem! 😉

    http://theosmblog.com/2009/07/25/fresh-install-wamp-codeigniter-running/

    Love, zatie

    Zatie Mei Gui

    March 31, 2011 at 8:19 am

  74. And thanks to Henri H for this post. Its excellent!

    Zatie Mei Gui

    March 31, 2011 at 8:20 am

  75. wahhhh thank’s bgt nehhh scriptnya CRUDnya brjalan dengan baik

    andrew

    April 19, 2011 at 4:32 am

  76. In the addPerson action, is it necessary to add the posted values to the $person array? Couldn’t the post array be simply passed in, like below?

    $id = $this->input->post(‘id’);
    $this->personModel->update($id,$this->input->post());

    Jonathan

    May 6, 2011 at 11:20 pm

  77. Many Thanks For Sharing, Sir

    kurniawan urip

    May 20, 2011 at 1:15 am

  78. Fantastic. Learned more in an hour than I ever thought possible. Thanks!

    Karl

    May 24, 2011 at 7:10 am

  79. Thanks its very helpful to me.

    Mahamud

    May 28, 2011 at 1:39 am

  80. […] – CodeIgniter Simple Explained https://henrihnr.wordpress.com/2009/04/26/simple-crud-application/ – Simple CRUD – CodeIgniter, мн добро […]

  81. […] will share the logic in the same edit function, and using a create or update approach. In the example provided by Henri, he used this approach to Add or Update a person. Simple […]

  82. ada kah tutorial yg lebih simpel terutama dibagian controller & view….and i like your model 😉

    hang2303

    June 9, 2011 at 1:21 am

  83. Hola

    Does anyone have a working copy of this with fixes for CodeIgniter 2.0.2 please?

    I have run into some problems and I would really like to get this working so I can learn more…

    Could anyone send to me or briefly host. Thanks…

    Gilberto

    June 18, 2011 at 4:51 am

  84. An Error Was Encountered
    Unable to locate the model you have specified: personmodel

    Gilberto

    June 18, 2011 at 5:16 am

  85. So – after a walk and some fresh air I’ve made some progress

    It seems that CI doesn’t like partially capatalised filenames as in personEdit.php etc…

    Fix: I had to rename the filenames and their instances in subsequent files

    Gilberto

    June 18, 2011 at 6:15 am

  86. So a problem now with “validation” — I have changed this to form_validation as per CI2.0.2

    and the View and Delete seem to work ok, but there is an error when navigating to ADD or EDIT

    Error: Fatal error: Call to undefined method CI_Form_validation::set_fields() in /…/crud/application/controllers/person.php on line 182

    Same error for both ADD and EDIT

    please someone with some CI experience might help me, thanks again

    Gilberto

    June 18, 2011 at 6:44 am

  87. I’m start learn CI using your code, then i make a little change. but i’m stuck when calling controlling using Routing. I want to used to do transaction using more than 1 table. Please help me.

    chandrachandra

    June 20, 2011 at 7:44 pm

  88. Kalau tabel A ada relasinya dg tabel B (mungkin dg tabel C juga) dg key tertentu gmn om?
    – Misal tabel A itu tabel person kyk contoh di atas,
    – trs tabel B nya misal tabel yg berisi data keluarga,
    – dan tabel C misalnya berisi data username/password/email..

    itu gmn om?

    luckyinfs

    June 25, 2011 at 2:24 am

  89. thanks brooo….

    dave

    June 30, 2011 at 6:25 am

  90. Think vey much for this tuto. It helps me a lot for my project in my entreprise.and I perform the code for codeigniter 2.
    but
    I have some problems with the date calendar.
    When I put null value, in my insert, I have the value of date:’1969-12-31′ .
    if some one resolved this pb?
    so, i look for a method for dependent drop-down lists for codeiginiter
    think

    Baradji

    July 8, 2011 at 8:27 pm

  91. Nice work Friend

    tulip

    July 21, 2011 at 7:11 pm

  92. kenapa malah
    Fatal error: Class ‘Controller’ not found in C:\xampp\htdocs\CodeIgniter\application\controllers\person.php on line 11

    ??? 😦 bantu sayaaaa

    Teman

    July 26, 2011 at 10:36 am

  93. thank you

    RZV

    July 28, 2011 at 4:42 pm

  94. change this part ::
    function valid_date($str)
    {
    if(!ereg(“^(0[1-9]|1[0-9]|2[0-9]|3[01])-(0[1-9]|1[012])-([0-9]{4})$”, $str))
    {
    $this->validation->set_message(‘valid_date’, ‘date format is not valid. dd-mm-yyyy’);
    return false;
    }
    else
    { return true;}}

    by this one::
    function checkDateFormat($date)
    {
    //match the format of the date
    if (preg_match (“/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/”, $date, $parts))
    {
    //check weather the date is valid of not
    if(checkdate($parts[2],$parts[3],$parts[1]))
    return true;
    else
    return false;
    }
    else
    return false;
    }

    gudluck 😉

    Ardini Sri Kartika

    July 31, 2011 at 9:34 pm

  95. gan, di ci 2.02 ga jalan…udh disesuaikan cuma masih blm jalan.. set_fields gimana ya…

    sholeh

    August 3, 2011 at 3:47 pm

  96. wah makasih tutorialnya, sangat membantu. belajar dari mencoba membuat sesuatu lebih cepat dari teori doank. great job many thanks

    anton hilman

    August 4, 2011 at 3:01 pm

  97. incredible, great tuts, find it after long time;))

    rakib006

    August 7, 2011 at 11:58 am

  98. Hi Henry,
    Great CRUD work and learnt many things from this. Is this possible to create transaction lines for a particular record? Say for example, for a small medical clinic, patient is returning customer. I want to keep their history, details and transaction every time they visit.

    Thank you for your help.
    Samuel

    Samuel

    August 23, 2011 at 2:10 pm

  99. Mantaps….ijin download bro.

    asriia03

    October 19, 2011 at 9:06 am

  100. Thanks Henri this blog really help me…

    I have a question how can you determine the ID of the row you want to delete???

    Neil

    October 22, 2011 at 8:26 am

  101. Does not work with CodeIgniter 2.0.3.
    Please suggest a fix asap.

    moomin

    October 22, 2011 at 12:39 pm

  102. You are awesome man! Thanks so much!

    Amit Gupta

    November 3, 2011 at 5:49 pm

  103. Very nice CRUD tutorial !!!

    I just modify one thing: when you edit/delete a record, you passes the “personID” into a GET var, that var should be encrypted for security issue.

    Apart from that is perfect!!!

    Thanks Again

    myky

    November 6, 2011 at 10:19 am

  104. HOW to run CRUD APPLICATION USING CODE IGNITER

    naga

    November 21, 2011 at 2:06 pm

  105. Need help and assistance what should I do about this??

    Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\CodeIgniterCRUD\system\codeigniter\Common.php on line 123
    Call Stack
    # Time Memory Function Location
    1 0.0005 683296 {main}( ) ..\index.php:0
    2 0.0013 743928 require_once( ‘C:\wamp\www\CodeIgniterCRUD\system\codeigniter\CodeIgniter.php’ ) ..\index.php:115

    ( ! ) Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\CodeIgniterCRUD\system\codeigniter\Common.php on line 129
    Call Stack
    # Time Memory Function Location
    1 0.0005 683296 {main}( ) ..\index.php:0
    2 0.0013 743928 require_once( ‘C:\wamp\www\CodeIgniterCRUD\system\codeigniter\CodeIgniter.php’ ) ..\index.php:115
    A PHP Error was encountered

    Severity: 8192

    Message: Function set_magic_quotes_runtime() is deprecated

    Filename: codeigniter/CodeIgniter.php

    Line Number: 60
    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: libraries/Loader.php

    Line Number: 248
    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: database/DB.php

    Line Number: 133

    wilfred05777

    November 23, 2011 at 3:41 am

  106. A PHP Error was encountered

    Severity: 8192

    Message: Function set_magic_quotes_runtime() is deprecated

    Filename: codeigniter/CodeIgniter.php

    Line Number: 60

    any fresh idea on how to solve this problem?

    wilfred05777

    November 23, 2011 at 3:43 am

  107. How Do I Solve this MR. HENRI?? please need some few advice for newbie on CI…

    A PHP Error was encountered

    Severity: 8192

    Message: Function set_magic_quotes_runtime() is deprecated

    Filename: codeigniter/CodeIgniter.php

    Line Number: 60
    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: libraries/Loader.php

    Line Number: 248
    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: database/DB.php

    Line Number: 133

    wilfred05777

    November 23, 2011 at 3:58 am

  108. IJIN SEDOT YAH GAN…. THANKS ANYWAY

    VIDEO BOKEP INDONESIA

    December 7, 2011 at 5:34 pm

  109. corregí el error de tipeo:
    escribiste: font-wight:bold;
    y deberia ser asi: font-weight:bold;

    Diego

    December 20, 2011 at 4:02 am

  110. now: font-wight:bold;
    will be: font-weight:bold;

    Diego

    December 20, 2011 at 4:02 am

  111. Great example. Learned a lot about CodeIgniter, PHP and HTML.
    I upgraded the example to work with Codeigniter 2.XX and newer PHP version – just minor changes, but help full for new guys.
    How can I send it?

    Jairo

    December 20, 2011 at 7:24 pm

  112. Just post the code in the comments the easiest and fastest way.

    Suomee

    December 20, 2011 at 7:34 pm

  113. When I am updating a row, all values are inserting as zeros in the row. When I see the data through this command “var_dump($_POST);” they are showing fine.

    Please help me urgently..

    ashoksharmaz87

    December 24, 2011 at 12:06 pm

  114. wowww mantep tutorialnya bro…
    thanks sharingnya, ane coba dulu 🙂

    tono

    January 11, 2012 at 6:26 pm

  115. Very nice script

    Rajesh

    January 17, 2012 at 6:17 pm

  116. @wilfred05777:

    That’s different PHP version. You can delete some “$” on your script

    Biron

    January 27, 2012 at 9:04 pm

  117. thank you so much for nice tutorial for new users

    Jitendra

    February 1, 2012 at 7:28 pm

  118. @wilfred05777:

    That’s different PHP version. You can delete some “$” on your script

    Biron
    January 27, 2012 at 9:04 pm

    Question: which of the files am I going to delete some “$” sign you said??
    is it in the controller, view or model?? please I need assistance…

    wilfred05777

    February 3, 2012 at 6:18 am

  119. pagination is not working???

    gordie

    February 16, 2012 at 11:01 pm

  120. awesome… Thank u V much…

    Siva

    February 17, 2012 at 3:53 pm

  121. hey… u made it look so easy..
    thanks..
    u saved me i was mugging around for this…..

    SUSHIL

    February 24, 2012 at 8:18 pm

  122. there was an error while im running your crud in CODEIGNITER ..

    heres the error:

    Fatal error: Class ‘Controller’ not found in C:\xampp\htdocs\CI\application\controllers\person.php on line 2

    i think i have problem in my adressing in the browser…

    josie cayton

    February 28, 2012 at 2:12 pm

  123. i have an error

    A Database Error Occurred

    Error Number: 1146

    Table ‘simplecrud.tbl_person’ doesn’t exist

    SELECT * FROM (`tbl_person`) ORDER BY `id` asc LIMIT 10

    Filename: C:\xampp\htdocs\crud12\system\database\DB_driver.php

    Line Number: 330

    can you help me on this!

    i download the source code, should i replace it the one’s you just posted above!

    darwin

    March 14, 2012 at 4:59 pm

  124. Please any one can help me, how to solve this error?

    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: CI_Form_validation::$id

    Filename: views/personEdit.php

    Line Number: 23
    ” />
    Name*
    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: CI_Form_validation::$name

    Filename: views/personEdit.php

    Line Number: 28
    “/>
    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: CI_Form_validation::$name

    Filename: views/personEdit.php

    Line Number: 29
    Gender* M F
    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: CI_Form_validation::$gender

    Filename: views/personEdit.php

    Line Number: 35
    Date of birth (dd-mm-yyyy)*
    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: CI_Form_validation::$dob

    Filename: views/personEdit.php

    Line Number: 39
    “/> calendar
    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: CI_Form_validation::$dob

    Filename: views/personEdit.php

    Line Number: 41

    Girish

    April 2, 2012 at 4:48 pm

  125. if you are click on add new data then these error are display, please help me for solve this error

    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: CI_Form_validation::$id

    Filename: views/personEdit.php

    Line Number: 23
    ” />

    Name*
    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: CI_Form_validation::$name

    Filename: views/personEdit.php

    Line Number: 28
    “/>

    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: CI_Form_validation::$name

    Filename: views/personEdit.php

    Line Number: 29
    Gender* M F
    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: CI_Form_validation::$gender

    Filename: views/personEdit.php

    Line Number: 35
    Date of birth (dd-mm-yyyy)*
    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: CI_Form_validation::$dob

    Filename: views/personEdit.php

    Line Number: 39
    “/> calendar
    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: CI_Form_validation::$dob

    Filename: views/personEdit.php

    Line Number: 41

    Girish Zope

    April 2, 2012 at 4:51 pm

  126. When I tried running the application, the browser returns “Forbidden You don’t have permission to access /CodeIgniter/index.php on this server. Apache/2.2.20 (Ubuntu) Server at localhost Port 80”

    What could be wrong?

    ivan

    April 7, 2012 at 8:40 am

  127. @Biron what $ sign you mean? where does it specifically located at??

  128. convert codeigniter 2.0 ?

    street

    April 12, 2012 at 9:20 am

  129. Thank you sir.

    this is very usefull tutorial.

    raju

    April 16, 2012 at 11:56 pm

  130. Iam getting this following error help me please.

    Deprecated: Assigning the return value of new by reference is deprecated in D:\xampplite\htdocs\curd\system\codeigniter\Common.php on line 123

    Deprecated: Assigning the return value of new by reference is deprecated in D:\xampplite\htdocs\curd\system\codeigniter\Common.php on line 129

    raju

    April 16, 2012 at 11:59 pm

  131. iam getting this please help me .

    Deprecated: Assigning the return value of new by reference is deprecated in D:\xampplite\htdocs\curd\system\codeigniter\Common.php on line 123

    Deprecated: Assigning the return value of new by reference is deprecated in D:\xampplite\htdocs\curd\system\codeigniter\Common.php on line 129
    A PHP Error was encountered

    Severity: 8192

    Message: Function set_magic_quotes_runtime() is deprecated

    Filename: codeigniter/CodeIgniter.php

    Line Number: 60

    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: database/DB.php

    Line Number: 133

    raju

    April 17, 2012 at 12:03 am

  132. Thank you Henry (sir). This tutorial gives me a lot of confidence. I can also work on Codeigniter. Thanks a lot Henry (sir).

    raju

    April 17, 2012 at 12:42 am

  133. Very very informative and one of the best tutorials on CRUD. Just love it. Thanks much!

    Mindi

    May 1, 2012 at 9:56 am

  134. how do i solve the deprecated issue on this??

    A PHP Error was encountered

    Severity: 8192

    Message: Function set_magic_quotes_runtime() is deprecated

    Filename: codeigniter/CodeIgniter.php

    Line Number: 60
    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: libraries/Loader.php

    Line Number: 248
    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: database/DB.php

    Line Number: 133

  135. i guess that´s a best tutorial ever…. thank you… i´ll follow your posts now… great job… sorry for bad english i´m brazilian.

    Elcio

    May 9, 2012 at 2:07 am

  136. Hi Friend , this tutoarial is nice , But when delete an entry there is a problem occur… If we have 12 entries
    and have 10 per page , in that case when we go to second page and delete 1 entry after deletion the page
    redirect to First page , in this CASE it’s ok … But if there is 122 entries , the admin feel bad about it , please fix that problem

    Thanks
    Anes

    Anes P A

    June 13, 2012 at 11:07 am

  137. Hey, you emailed me requesting backlinks (to help build more traffic to your site) I’m sold up and retired now (woo hoo), so I can’t help personally, but I used a service for $39/mo while secretly marking up the price to $400-500 and selling this same service to many clients. the link is http://goo.gl/KlDCN

    Virtue Vase

    July 2, 2012 at 3:21 pm

  138. OH bro you really greate for me. I, m facing many more problem in ci, but i got this my problem is solved…..

    bimal chand

    July 3, 2012 at 4:35 pm

  139. i want to create a admin panel for Admin login please help me

    Arvind Sharma

    July 11, 2012 at 11:34 am

  140. Sir i getting this error pls help me

    Deprecated: Assigning the return value of new by reference is deprecated in /var/www/projects/Codeigniter/system/codeigniter/Common.php on line 130

    Deprecated: Assigning the return value of new by reference is deprecated in /var/www/projects/Codeigniter/system/codeigniter/Common.php on line 136
    A PHP Error was encountered

    Severity: 8192

    Message: Function set_magic_quotes_runtime() is deprecated

    Filename: codeigniter/CodeIgniter.php

    Line Number: 60
    An Error Was Encountered

    The URI you submitted has disallowed characters.

    arvind

    July 11, 2012 at 12:52 pm

  141. hi Henry!~

    Thanks a lot!

    I love you! 😉

    Leslie

    July 12, 2012 at 9:39 am

  142. […] The CMS is a PHP/MySQL-based project built via CodeIgniter (http://codeigniter.com/) The version used is 2.0.3; as of this writing CodeIgniter may be up to Version 2.1.2. Portions of the CMS are based in turn on a CodeIgniter 1.6.2 tutorial readapted for 2.0.3: https://henrihnr.wordpress.com/2009/04/26/simple-crud-application/ […]

  143. When inserting any number in a row and displayed in a table it is shown as 0, while I see in the database it is correct. Any guest why it is?

    vj86

    July 25, 2012 at 10:23 pm

  144. I couldn’t refrain from commenting. Exceptionally well written! Check out my website to get more info about bodybuilding, if you like.

    creatine kinase

    August 7, 2012 at 11:56 pm

  145. […] Clique aqui para acessar o post Share this:LinkedInFacebookTwitterGostar disso:GosteiSeja o primeiro a gostar disso. […]

  146. You’re so interesting! I don’t think I’ve truly read a single thing like that before. So great to discover someone with a few unique thoughts on this subject. Seriously.. thank you for starting this up. This web site is one thing that is required on the web, someone with some originality!

    google merchant account

    September 9, 2012 at 1:52 am

  147. hi henri…nice tutorial…
    but i have an error…
    i’m trying to do the validation in my form following your tutorial…but it said unable to load requested language file…
    what i did is exactly like you showed in your tutorial…
    may be you know the problem, i’m waiting for your reply…thanks…

    Laras Ervintyana

    September 18, 2012 at 8:24 am

  148. Very nice Tutorial ! Thanks Man…

    Jesus Christ

    September 18, 2012 at 9:38 am

  149. Thank you for this! 🙂 But I’m still confused on what to pud in the browser’s url. I hope you could help me.

    Maria Clara

    September 23, 2012 at 8:35 am

  150. @Laras Ervintyana

    See the CI version above and the version of your CI 🙂

    Semahaj Olanam Rellertse

    September 25, 2012 at 11:36 pm

  151. Hi mates, pleasant paragraph and good arguments commented here,
    I am truly enjoying by these.

    filtres a cartouche

    September 30, 2012 at 2:22 pm

  152. Hi Henri,
    Nice Work. I am getting class validation error and I am not able to edit/update/add a file. Please helpl . and please help me if I have to submit a new form into the same db tbl_person. What MVC things should i Use.

    faheemmir

    October 3, 2012 at 3:44 pm

  153. http://denvermortgage.pro I ask all my pals to pay a visit to this blog.. br .. and I hope they’ll absolutely like..

    mShaneBoazbbug

    October 12, 2012 at 1:12 am

  154. masih error scriptnya br

    A PHP Error was encountered

    Severity: Warning

    Message: Creating default object from empty value

    Filename: controllers/person.php

    Line Number: 190
    saat mau nambah file dan update file.. tolong updatenya donk. terima kasih

    andi

    October 13, 2012 at 3:00 am

  155. A PHP Error was encountered

    Severity: Warning

    Message: Creating default object from empty value

    Filename: controllers/person.php

    Line Number: 129
    ini pas mau update .. error kayak di atas.. minta updatenya donk.. terima kasih

    andi

    October 13, 2012 at 3:01 am

  156. Great! Finished my module within one hour… Thank you so much!

    Raja MM

    November 2, 2012 at 2:20 pm

  157. An Error Was Encountered

    Unable to load the requested class: validation

    ???

    jass

    November 15, 2012 at 1:11 pm

  158. awesome.
    great for me. very helpful. 🙂

    Airgle

    November 20, 2012 at 9:42 am

  159. Thanks for this.
    and keep sharing

    Airgle

    November 20, 2012 at 9:44 am

  160. thanks you so much… now, i know this code how’s it work………………
    very helpful

    But i have one problem in the code. Validation is not working in the code. So, Please give me idea on that…

    And Display error like that

    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: person::$validation

    Filename: controllers/person.php

    Line Number: 181

    Fatal error: Call to a member function set_fields() on a non-object in G:\xampp\htdocs\codeigniter_register\application\controllers\person.php on line 181

    Priyanka

    December 11, 2012 at 6:49 pm

  161. bagus banget
    ijin download gan

    Ade Reza R S

    December 17, 2012 at 11:21 am

  162. *************************IMPORTANT*******************+
    for all problems, you have to put on your config.php file

    $config[‘base_url’] = ‘http://localhost’; instead of ‘http://crud-ci2.localhost/’;

    and also put your files on the WWW directory (all other files move into another directory) or modify the DocumentRoot “c:/wamp/www/” for DocumentRoot “c:/wamp/www/crud-ci2/” on your httpd.conf apache file

    good luck

    Claudio

    January 10, 2013 at 10:59 pm

  163. awesome.
    great for me. very helpful.

    Thomas Varghese

    January 31, 2013 at 5:42 pm

  164. wedew…mantaph mastah codingx..bagi2 ilmux selaluw yak. thanks

    Cinta Dia

    February 14, 2013 at 10:09 am

  165. How can i run this application in xampp

    Amit Kansal

    February 25, 2013 at 6:55 pm

  166. How can i
    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\htdocs\CodeIgniter\system\codeigniter\Common.php on line 123

    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\htdocs\CodeIgniter\system\codeigniter\Common.php on line 129
    A PHP Error was encountered

    Severity: 8192

    Message: Function set_magic_quotes_runtime() is deprecated

    Filename: codeigniter/CodeIgniter.php

    Line Number: 60

    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: libraries/Loader.php

    Line Number: 248

    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: database/DB.php

    Line Number: 133

    Simple CRUD Application

    NO NAME GENDER DATE OF BIRTH (DD-MM-YYYY) ACTIONS
    1 henrihnr Male 09-09-1985 view update delete
    2 name_001 Male 01-01-1990 view update delete
    3 name_002 Female 01-01-2000 view update delete
    4 name_003 Male 02-02-2000 view update delete
    5 name_005 Female 04-04-2000 view update delete

    add new datarun this application in xampp

    Please help me

    Amit Kansal

    February 25, 2013 at 7:02 pm

  167. Now everything is fine but while i am adding data it is showing

    The URI you submitted has disallowed characters.

    Amit Kansal

    February 25, 2013 at 7:16 pm

  168. LouisVuittonBagsAidsWickedCapabilitiesMethods,[url=http://www.vuittontenpo.com/]ルイヴィトン バッグ[/url],LvHandbagsOutletVeryShow!,http://vuittontenpo.com/,$32MLouisVuittonVerdictShowsLimitsWithRegardsToIspSafePorts

    carpytnteyrouey

    April 10, 2013 at 11:18 am

  169. Thanks for your write-up. I also feel that laptop computers have gotten more and more popular lately, and
    now will often be the only kind of computer used in a household.
    This is due to the fact that at the same time they are becoming more and more inexpensive, their computing power is growing to
    the point where these are as strong as pc’s coming from just a few in years past.

    Lorraine

    April 21, 2013 at 4:16 pm

  170. There’s definately a lot to learn about this topic. I love all the points you have made.

  171. What’s up, of course this paragraph is in fact pleasant and I have learned lot of things from it regarding blogging. thanks.

    hair removal

    June 1, 2013 at 2:45 pm

  172. hi please help when i want to edit this error message show in the header

    A PHP Error was encountered

    Severity: Warning

    Message: Creating default object from empty value

    Filename: controllers/person.php

    Line Number: 130

    threadbooster

    June 17, 2013 at 2:15 pm

  173. Hello would you mind stating which blog platform you’re working with? I’m going to start
    my own blog soon but I’m having a difficult time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design seems different then most blogs and I’m looking for something unique.
    P.S Sorry for getting off-topic but I had to ask!

  174. thank alot to give such a wonderful code

    dfg

    July 2, 2013 at 1:53 pm

  175. The actual bingo halls are usually creating method for on-line bingo bedrooms.
    You will find mainly a couple several types of bonus deals throughout on the internet bingo

    Grand Parker

    July 14, 2013 at 5:50 am

  176. How to fix this error thanks:
    __________________________

    A PHP Error was encountered

    Severity: Warning

    Message: Creating default object from empty value

    Filename: controllers/team.php

    Line Number: 128

    bot

    July 16, 2013 at 1:25 pm

  177. To answer my previous answer here is the answer.

    Just add this

    function _set_fields()
    {
    $this->form_data = new stdClass();
    /some code here
    }

    reference: http://www.trash-factor.com/content/php-error-creating-default-object-empty-value

    bot

    July 16, 2013 at 1:50 pm

  178. Very Good

    thank you!!!!

    Atam HEMAT

    July 16, 2013 at 1:59 pm

  179. it is applicable to codeigniter 2.1.4??? i tried to load but the welcome message is always appeared.

    King

    July 27, 2013 at 11:41 am

  180. SCRIPT ERROR..?

    Ricco Anggara

    August 15, 2013 at 2:30 pm

  181. Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\htdocs\CodeIgniter\system\codeigniter\Common.php on line 123

    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\htdocs\CodeIgniter\system\codeigniter\Common.php on line 129
    A PHP Error was encountered

    Severity: 8192

    Message: Function set_magic_quotes_runtime() is deprecated

    Filename: codeigniter/CodeIgniter.php

    Line Number: 60

    rajendra

    August 28, 2013 at 8:37 pm

  182. Thank for this tutorial, bro…. i wanna ask u. when i was click ‘add new data’ then show some trouble :

    A PHP Error was encountered
    Severity: Warning
    Message: Creating default object from empty value
    Filename: controllers/person.php
    Line Number: 190

    Can u explain and solve case above.? thanks before…, but overall the function can running very well. only statement above is a bit annoying

    regards
    Dim’s from indonesia

    dim's

    September 16, 2013 at 3:24 pm

  183. @rajendra go to index.php and set error_reporting(E_ALL) to error_reporting(E_ALL & ~E_DEPRECATED);

    or try changing set_magic_quotes_runtime(0); to ini_set(“magic_quotes_runtime”, 0);

    i guess it’s a problem with your php version.

    @henrihnr this is the best! 😀

    phyll

    September 19, 2013 at 3:01 am

  184. nice tutorial… love it. thanks..

    Slamet Budi Santoso

    November 4, 2013 at 6:39 am

  185. I have it working for the most part, but I am adding additional date fields and the datepicker does not work on any file not named dob…any suggestions?

    Reese Troute

    November 13, 2013 at 7:25 am

  186. To stop the errors

    function _set_fields()
    {
    $this->form_data = new stdClass;
    $this->form_data->id = ”;
    $this->form_data->name = ”;
    $this->form_data->gender = ”;
    $this->form_data->dob = ”;
    }

    Michael

    November 22, 2013 at 1:05 am

  187. thanks

    sopian

    December 1, 2013 at 10:58 am

  188. Reblogged this on ::.

    cacingus

    December 8, 2013 at 7:18 pm

  189. Fatal error: Class ‘Controller’ not found in C:\xampp\htdocs\datakaryawan\application\controllers\person.php on line 2

    help me

    eddy

    January 5, 2014 at 6:48 pm

  190. Hi Henri Thanks for the super awesome CI crud app. Very well explained. But I have a question.
    I used this Person files and used the same files as Department. I did edit all the other relative fields. But the Department Controller file do not load the index method in it. But Person function very well. Can someone please help me with this?.

    sophia

    January 27, 2014 at 3:07 pm

  191. its very nice my dear friend this is what really i need
    thank u very much

    pradeep

    February 12, 2014 at 1:45 pm

  192. I am Manuja Sudasingha.Very very good example you have given..Thank you.

    Manuja Sudasingha

    March 5, 2014 at 11:08 am

  193. Hi Henri!
    Tell me please: how to make adding/editing entries on the form of the General list, and not in a separate form?
    Thank you!

    Aleksey

    April 21, 2014 at 6:30 pm

  194. awesome article. This is what I have been finding for a long time
    Thanks very much.

    kamza

    May 23, 2014 at 1:42 pm

  195. Hey there just wanted to give you a quick heads up and let you know a few of the images aren’t loading correctly.
    I’m not sure why but I think its a linking issue.

    I’ve tried it in two different web browsers and both show the same results.

    steeldrumband.info

    July 5, 2014 at 4:09 pm

  196. Hi Henrihnr, Thanks a lot for taking time to write this valuable post and sharing with us. Im new to CI in learning over internet tutorial yours is simple to learn CRUD. This code works fine for me. But Im having a small doubt. In all other tutorials the model and controller are extends from CI_Model and CI_Controller but yours is not. Can you please guide me on this…

    Charles

    July 18, 2014 at 10:35 pm

  197. Nice Tutorial…i got useful information from this tutorial,here is a way to findsimple registration form using codeigniter

    simple

    October 5, 2014 at 1:57 pm

  198. very nice tutorial for php developer, when refresh this page add same data in table, how to prevent this type of entry

    Thanks

    sanjay kumar

    October 12, 2014 at 2:37 pm

  199. thanks its really helpful for me,

    ffff

    October 28, 2014 at 8:55 pm

  200. […] Simple CRUD – CodeIgniter – Henri Blog | Study and … – Apr 26, 2009 · Nice tutorial, when i started with codeigniter this is the tutorial that really helped me in expediting the project great job… […]

  201. Deprecated: Assigning the return value of new by reference is deprecated in C:\newwamp\www\CodeIgniters\system\codeigniter\Common.php on line 123
    Call Stack
    # Time Memory Function Location
    1 0.0008 375352 {main}( ) ..\index.php:0
    2 0.0036 423168 require_once( ‘C:\newwamp\www\CodeIgniters\system\codeigniter\CodeIgniter.php’ ) ..\index.php:115

    ( ! ) Deprecated: Assigning the return value of new by reference is deprecated in C:\newwamp\www\CodeIgniters\system\codeigniter\Common.php on line 129
    Call Stack
    # Time Memory Function Location
    1 0.0008 375352 {main}( ) ..\index.php:0
    2 0.0036 423168 require_once( ‘C:\newwamp\www\CodeIgniters\system\codeigniter\CodeIgniter.php’ ) ..\index.php:115
    A PHP Error was encountered

    Severity: 8192

    Message: Function set_magic_quotes_runtime() is deprecated

    Filename: codeigniter/CodeIgniter.php

    Line Number: 60
    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: libraries/Loader.php

    Line Number: 248
    A PHP Error was encountered

    Severity: 8192

    Message: Assigning the return value of new by reference is deprecated

    Filename: database/DB.php

    Line Number: 133

    That show this type error .please solve this type error and give replay

    raj

    November 22, 2014 at 1:28 pm

  202. […] PDF File Name: Simple crud – codeigniter – henri blog | study and share Source: henrihnr.wordpress.com » DOWNLOAD « […]

    Contoh Script Codeigniter

    January 8, 2015 at 3:38 am

  203. hey…it shows the error
    The URI you submitted has disallowed characters.
    my codeigniter version is 2.2.1 and php version is 5.5.12

    Manish

    February 16, 2015 at 7:54 pm

  204. when i click the add new data, this will be the output:

    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: Person::$validation

    Filename: controllers/person.php

    Line Number: 177

    Fatal error: Call to a member function set_fields() on a non-object in C:\xampp\htdocs\crud_CI\application\controllers\person.php on line 177

    kiddie

    February 26, 2015 at 5:19 pm

  205. go to application/config/autoload.php

    add in library

    example :

    $autoload[‘libraries’] = array(‘database’,’session’,’form_validation’,’table’);

    Thanks

    sanjay yadav

    February 26, 2015 at 8:24 pm

  206. Great Post. I just want to share this site PDFFiller, Inc which I use to eSign my documents. I can also get third party digital signatures from my employees and clients. You can get a free trial if you ask for it.
    http://go.gl/SA1pfw

    Jill Rivas

    March 3, 2015 at 8:20 am

  207. thanks a lot. It’s very helpful tutorials.

  208. Simply awesome! Very Thank! is just I needed.
    My blog is http://www.programertech.com.ar if you wan see my posts about technologies

    Alejandro

    May 15, 2015 at 4:17 am

  209. thanks sir am doing work on curd with the help of your code thanku

    AMANDEEP KAUR

    August 5, 2015 at 4:46 pm

  210. I do not even understand how I finished up here, but I thought this put up used to be great. I don’t recognize who you’re however definitely you are going to a famous blogger if you happen to aren’t already Cheers!

    Ralph Chubicks

    March 20, 2016 at 3:35 pm

  211. Its vital to do your homework into which trading platform to trade with before you decide which broker to use check out this site it has a list of broker’s reviews

    Oscar Kane

    March 21, 2016 at 5:58 pm

  212. Good.we can auto create crud in codeigniter with our inputs using http://crudgenerator.in

    phpdreamworld

    April 24, 2016 at 9:15 pm

  213. Thank you for sharing your great suggestions. I have a site ” http://www.musicinstruments.tv ” which promotes and shares new talent and some pros with their videos. Verify it out! I am always browsing for new ideas.

    Rocky Manheim

    April 30, 2016 at 4:47 am

  214. Just wanna input on few general things, The website design is perfect, the content is rattling good : D.

    Beatrice Krzesinski

    August 19, 2016 at 8:22 pm

  215. Highly informative look forwards to returning. http://bit.ly/2f0xJ92

    New healthy man

    November 12, 2016 at 5:38 am

  216. Breaking the Silence of the Lambs

    Breana Bovard

    November 27, 2016 at 8:13 am

  217. I¡¦ve been exploring for a little for any high-quality articles or weblog posts in this kind of area . Exploring in Yahoo I finally stumbled upon this site. Studying this info So i am glad to show that I’ve an incredibly just right uncanny feeling I found out exactly what I needed. I so much undoubtedly will make sure to don¡¦t forget this site and give it a glance on a continuing basis.

    Zachary Mcclave

    December 1, 2016 at 12:56 pm

  218. Having read this I believed it was extremely enlightening. I appreciate you finding the time and effort to put this informative article together. I once again find myself spending a lot of time both reading and commenting. But so what, it was still worthwhile!|

    Nicky Kagle

    December 4, 2016 at 8:59 pm

  219. Howdy very nice site!! Man .. Beautiful .. Wonderful .. I will bookmark your website and take the feeds additionally¡KI am glad to seek out so many helpful info right here within the publish, we’d like develop extra techniques on this regard, thank you for sharing. . . . . .

    Aiko Carreker

    December 8, 2016 at 8:39 am

  220. I dugg some of you post as I cogitated they were very beneficial very helpful

    Lorrie Pallant

    December 14, 2016 at 10:28 pm

  221. You have mentioned very interesting details ! ps nice site. “I understand a fury in your words, But not the words.” by William Shakespeare.

    Carmine Rinkus

    December 22, 2016 at 12:57 am

  222. Have you ever considered creating an ebook or guest authoring on other blogs?I have a blog based on the same subjects you discuss and would love to have you share some stories/information. I know my visitors would enjoy your work.If you are even remotely interested, feel free to shoot me an e-mail.

    Luciano Peddy

    December 25, 2016 at 7:51 am

  223. Many thanks, this site is really handy.|

    Kurtis Gnagey

    December 29, 2016 at 8:47 pm

  224. I’m gone to inform my little brother, that he should also visit this weblog on regular basis to take updated from newest gossip.|

    Davina Lompa

    January 5, 2017 at 3:57 am

  225. Simply want to say your article is as astonishing. The clarity on your put up is simply nice and that i can suppose you are knowledgeable in this subject. Well with your permission let me to grab your feed to stay updated with impending post. Thank you 1,000,000 and please keep up the enjoyable work.|

    Valrie Lobell

    January 19, 2017 at 11:28 pm

  226. you’re really a just right webmaster. The website loading pace is amazing. It sort of feels that you’re doing any distinctive trick. Furthermore, The contents are masterpiece. you’ve done a magnificent activity on this matter!

    Russ Giacomo

    January 22, 2017 at 4:09 am

  227. you’re truly a excellent webmaster. The site loading speed is amazing. It kind of feels that you’re doing any unique trick. Also, The contents are masterpiece. you’ve done a fantastic job in this subject!

    Lorrine Roets

    January 23, 2017 at 4:19 am

  228. ※当店の商品は全て国内正規販売元の検品を経て納品された商品を販売しております。 ポンチョカーディガン

    Alexander Tozier

    February 3, 2017 at 7:51 pm

  229. I was studying some of your posts on this site and I conceive this site is very instructive! Retain putting up.

    Sachiko Janus

    February 4, 2017 at 6:39 pm

  230. Thankfulness to my father who told me on the topic of this website, this website is truly remarkable.|

    Dara Howdyshell

    February 10, 2017 at 12:12 am

  231. Yeah, Afi is fast as a shark when it comes to try new games,
    especially when these games are alive at one of his favorite casinos, Casumo.

    serchup.com

    September 1, 2017 at 6:02 pm

  232. Our community is better because you are in it. When I turned on my browser this website was running. You have a lot of knowledge on this subject.

    Jesse Grillo

    September 6, 2017 at 4:53 am

  233. I will post a website link to this page on my weblog. I am absolutely sure my site visitors will find that incredibly useful.

    Desire Takaoka

    January 20, 2018 at 9:54 pm

  234. […] Simple CRUD – CodeIgniter | Henri Blog – Apr 26, 2009  · A couple months ago i have developed PHP application. That’s was the first time (and the only one) i used CodeIgniter. The development itself only took a. […]

    Why Ada Trading Bot |

    February 21, 2018 at 5:03 pm

  235. Thank you for sharing your information on creating applications. I think I will also start this, now I’m editing the forms on https://www.pdffiller.com/

    Dorothy Bishop

    March 6, 2018 at 8:11 pm


Leave a comment