title: how to display validation error under the each input field on redirect in codeigniter
body: <p>I am validating a form in codeigniter. If the user did not fill in the form correctly, then the page should not redirect to any other page, but display errors on each input field. Here is my code of form:</p>
  
  <pre><code>&lt;?php  echo $this-&gt;session-&gt;flashdata('errors');?&gt;
  &lt;form action="&lt;?php echo base_url() ?&gt;detail/travel" method="post"&gt;
  
  &lt;input type="text" name="departure"&gt;
  &lt;input type="text" name="destination"&gt;
  &lt;input type="text" name="name"&gt;
  &lt;input type="text" name="cell"&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>and here is my method code:</p>
  
  <pre><code>function search_travel(){
                  if($_POST){
  
                      $config = array(
                      array(
                      'field'=&gt;'departure',
                      'label'=&gt;'departure',
  
                  'rules'=&gt;'trim|required|alpha'
                  ),
                  array(
                  'field'=&gt;'destination',
                  'label'=&gt;'destination',
                  'rules'=&gt;'trim|required|alpha'
                  ),
                  array(
                  'field'=&gt;'name',
                  'label'=&gt;'name',
                  'rules'=&gt;'trim|required|alpha'
                  ),
                  array(
                  'field'=&gt;'cell',
                  'label'=&gt;'cell no',
                  'rules'=&gt;'trim|required'
                  )
              );
          $this-&gt;load-&gt;library('form_validation');
          $this-&gt;load-&gt;helper(array('form', 'url'));
          $this-&gt;form_validation-&gt;set_rules($config);
  
          if($this-&gt;form_validation-&gt;run() == FALSE){
              $this-&gt;session-&gt;set_flashdata('errors', validation_errors());
               redirect(base_url());
              }
      }
  </code></pre>
  
  <p>}</p>
  
  <p>The problem is that by using set_flashdata I can't use form_error function and set_value function. Is there any other solution to this problem??? </p>