php - new article is not getting submitted in codeigniter -


<?php class admin extends my_controller     {         public function dashboard()             {                 /*                 if(! $this->session->userdata('user_id')) // condition check condition show dashboard if person logged in else redirect login page.                     return redirect('login');                 */                  $this->load->model('articlesmodel','articles');  // "articles" secondary name have given here , refering to.                 $articles = $this->articles->articles_list();   // if have given secondary name need use seconary name here too.                 // in above line, titles/title stored in $articles.                   $this->load->view('admin/dashboard.php',['articles'=>$articles]); // passing received articles in here.                 // above 'articles' received "dashboard.php" in form of "$articles".             }               public function add_article()             {                 $this->load->helper('form');                 $this->load->view('admin/add_article.php');             }               public function store_article()             {                 // use form validate same file. but, have set rules , in config's form_validation file.                 // need pass rule in run below.                 $this->load->library('form_validation');                 if($this->form_validation->run('add_articles_rules'))                 {                     // if pass parameter inside post value else give inputs in array.                      $post = $this->input->post();                     unset($post['submit']); // remove submit value received in $post array else give error.                      $this->load->model('articlesmodel','articles');                     if($this->articles->add_article($post))                     {                         echo "insert sucessful";                     }                     else                     {                         echo "insert uncessful";                     }                 }                  else                 {                     return redirect('admin/add_article');                 }             }               public function edit_article()             {              }              public function delete_article()             {              }              public function __construct()                 {                     parent::__construct();                     if(! $this->session->userdata('user_id'))                         return redirect('login');                 }                 // above constructor can placed in my_controller need undo "login extends my_controller" or make                  // "login extends ci_controller" in "admin" file can have more methods.     }            ?> 


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -