title: how to show error message in codeigniter
body: <p>I am new on codeigniter and creating form which is sending data to mail.
  Now I am working on form validation .
  I want if any one click on submit button without filling form data then error should be shown in the placeholder in text box.
  Here is my contact_us_view page in view</p>
  
  <pre><code>&lt;?php 
          $form=array('class'=&gt;'contact-form default-form','id'=&gt;'myform');
          echo form_open('success_form',$form);
          ?&gt;
          &lt;div class="row"&gt;
  
            &lt;div class="col-md-12"&gt;
              &lt;div class="preamble col-md-12"&gt;
                &lt;h3&gt;Get in touch&lt;/h3&gt;
              &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class="col-md-6"&gt;
              &lt;?php
              $name=array('placeholder'=&gt;'Name','name'=&gt;'name');
              echo form_input($name);
              ?&gt;
            &lt;/div&gt;
            &lt;div class="col-md-6"&gt;
              &lt;?php
              $company=array('placeholder'=&gt;'Company','name'=&gt;'company');
              echo form_input($company);
              ?&gt;
            &lt;/div&gt;
            &lt;div class="col-md-6"&gt;
              &lt;?php
              $number=array('placeholder'=&gt;'Phone Number','name'=&gt;'number');
              echo form_input($number);
              ?&gt;
            &lt;/div&gt;
            &lt;div class="col-md-6"&gt;
              &lt;?php
              $email=array('placeholder'=&gt;'Email','name'=&gt;'email');
              echo form_input($email);
              ?&gt;
            &lt;/div&gt;
            &lt;div class="col-md-6"&gt;
              &lt;span class="arrival calendar"&gt;
              &lt;?php
              $arrival=array('name'=&gt;'arrival','placeholder'=&gt;'Arrival','data-dateformat'=&gt;'m/d/y');
              echo form_input($arrival);
              ?&gt;
                  &lt;i class="fa fa-calendar"&gt;&lt;/i&gt;
              &lt;/span&gt;
            &lt;/div&gt;
            &lt;div class="col-md-6"&gt;
              &lt;span class="departure calendar"&gt;
              &lt;?php
              $departure=array('name'=&gt;'departure','placeholder'=&gt;'Departure','data-dateformat'=&gt;'m/d/y');
              echo form_input($arrival);
              ?&gt;
                 &lt;i class="fa fa-calendar"&gt;&lt;/i&gt;
              &lt;/span&gt;
            &lt;/div&gt;
            &lt;div class="col-md-12"&gt;
  
              &lt;span class="select-box" title="hotel-type"&gt;
                &lt;select name="person" data-placeholder="Number of People"&gt;
                  &lt;option value="1"&gt;1&lt;/option&gt;
                  &lt;option value="2"&gt;2&lt;/option&gt;
                  &lt;option value="3"&gt;3&lt;/option&gt;
                  &lt;option value="4"&gt;4&lt;/option&gt;
                  &lt;option value="5"&gt;5&lt;/option&gt;
                  &lt;option value="6"&gt;6&lt;/option&gt;
                  &lt;option value="7"&gt;7&lt;/option&gt;
                  &lt;option value="8"&gt;8&lt;/option&gt;
                  &lt;option value="9"&gt;9&lt;/option&gt;
                  &lt;option value="10"&gt;10&lt;/option&gt;
                  &lt;option value="10+"&gt;10+&lt;/option&gt;
                &lt;/select&gt;
              &lt;/span&gt;
            &lt;/div&gt;
            &lt;div class="col-md-12"&gt;
              &lt;textarea placeholder="How we can help you"&gt;&lt;/textarea&gt;
            &lt;/div&gt;
            &lt;div class="col-lg-md text-center"&gt;
              &lt;button class="btn btn-transparent-white"&gt;Send Message&lt;/button&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;?php echo form_close();?&gt;
  </code></pre>
  
  <p>here is my controller success_form in controller</p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class Success_form extends CI_Controller{
  
      public function __construct() {
          parent::__construct();
          $this-&gt;load-&gt;library(array('session', 'form_validation', 'email'));
      }
  
      public function index(){
  
          // Set Validation Rule
  
          $this-&gt;form_validation-&gt;set_rules('name','Name','trim|required|xss_clean|callback_alpha_space_only','required');
          $this-&gt;form_validation-&gt;set_rules('company','Company','trim|required|xss_clean|callback_alpha_space_only');
          $this-&gt;form_validation-&gt;set_rules('number','Mobile Number','required|regex_match[/^[0-9]{10}$/]');
          $this-&gt;form_validation-&gt;set_rules('email', 'Emaid ID', 'trim|required|valid_email');
          $this-&gt;form_validation-&gt;set_rules('arrival','Arrival','trim|required|xss_clean');
          $this-&gt;form_validation-&gt;set_rules('departure','Departure','trim|required|xss_clean');
          $this-&gt;form_validation-&gt;set_rules('person','Number of Person','trim|required|xss_clean|numeric');
  
  
      //Run Validation on Form Input
  
      if($this-&gt;form_validation-&gt;run()==FALSE){
       // Validation fails
          $this-&gt;load-&gt;view('contact_us_view');
      }
      else{
          echo "successfully";
      }
      }
  
  }
  </code></pre>
  
  <p>without filling form if any one click on submit button then error should be shown in placeholder of form.
  please help me to find out the answer ..i try lot but didnt get solution ..please help</p>