title: How to get validation errors in codeigniter?
body: <p>Hello I am inserting data in database. When I insert both category and description then data in inserting but when I don't insert in the category and description input and click on create then no error showing with blank page admin/category/ register_category, I want to show that category and description field should not be empty.</p>
  
  <h3>category.php view page is below :</h3>
  
  <pre><code>&lt;?php if(isset($_SESSION['success'])){ ?&gt;
      &lt;div class="alert alert-success"&gt;&lt;?php echo $_SESSION['success']; ?&gt; 
      &lt;/div&gt;
  &lt;?php } ?&gt;
  &lt;?php echo validation_errors('&lt;div class="alert alert-danger"&gt;','&lt;/div&gt;'); ?&gt;
  
  &lt;form class="form" action="&lt;?php echo site_url('admin/category/register_category') ?&gt;" method="POST"&gt;
      &lt;label for="contactinput5"&gt;Category Name&lt;/label&gt;
      &lt;input class="form-control border-primary" type="text" placeholder="category" name="category" id="contactinput5"&gt;
      &lt;label for="contactinput5"&gt;Discription&lt;/label&gt;
      &lt;textarea class="form-control border-primary" type="text" placeholder="discription" name="discription" id="contactemail5"&gt;&lt;/textarea&gt;
      &lt;button type="submit" name="create" class="btn btn-primary"&gt;
  </code></pre>
  
  <h3>and my controller Category.php page is:</h3>
  
  <pre><code>&lt;?php
  class Category extends CI_Controller {
      function index() {
          $this-&gt;load-&gt;view('admin/category');
      }
  
      function register_category() {      
          $this-&gt;form_validation-&gt;set_rules('category', 'Category', 'required');
          $this-&gt;form_validation-&gt;set_rules('discription', 'Discription', 'required');
          if($this-&gt;form_validation-&gt;run() == TRUE){
              echo "form validate";
              $this-&gt;load-&gt;model('categories');
              $insert_category = $this-&gt;categories-&gt;validate();
              if($insert_category){
                  $this-&gt;session-&gt;set_flashdata("success","Your data has been added");
                  redirect("admin/category","refresh");
              }
              else{
                  redirect('admin/category');
              }
          }
      }
  }
  ?&gt;  
  </code></pre>
  
  <h3>model categories page:</h3>
  
  <pre><code>&lt;?php
  class Categories extends CI_Model
  {
       function validate()
      {
          $arr['categoryname'] =  $this-&gt;input-&gt;post('category');
          $arr['discription'] =   $this-&gt;input-&gt;post('discription');
          return $this-&gt;db-&gt;insert('category',$arr);      
      }
  }
  ?&gt;
  </code></pre>