Skip to Content
PHPCODE
CodeIgnite Insert Article
codeigniter code / August 1, 2018

Insert Article in codeigniter

Step 1:- Created model articlesmodel.php

public function add_article($array)
{
return $this->db->insert(‘articles’,$array);
}

step 2 :- Created controller admin.php

public function store_article()
{
$this->load->library(‘form_validation’);

if($this->form_validation->run(‘add_article_rules’))
{
$post=$this->input->post();
$this->load->model(‘articlesmodel’,’articles’);
if($this->articles->add_article($post))
{
//flash message insert successfull
echo “insert successful”;
}
else
{
//insert failed.
echo “insert Failed”;
}
}
else
{
$this->load->view(‘admin/add_article’);
}
}

PHPCODE © 2024