title: How to pass validation error data through redirect()?
body: <p>I have a page that contains a form and when any user submits it, the data goes to a controller and the controller checks the validation, if there is any error it redirects the user to the previous page( the page that contains the form), otherwise it sends data to models. </p>
  
  <p>To redirect to the previous page from controller (if there is any validation error), I have the following code</p>
  
  <pre><code>        redirect($this-&gt;input-&gt;post('redirect'));
  </code></pre>
  
  <p>The above code is working fine but the problem is after it redirects the user to the previous page(The page that contains the form) it is not displaying the validation errors.</p>
  
  <p>So would you please kindly tell me how to pass the validation error information through this  "redirect" code I posted above and show the validation error message on that page?</p>
  
  <p>Thanks in Advance :)</p>
  
  <h1>Solution: </h1>
  
  <p>In my controller:</p>
  
  <pre><code>   $redirect=$this-&gt;input-&gt;post('redirect'); //  &lt;&lt; for this I have- &lt;input name="redirect" type="hidden" value="&lt;?= $this-&gt;uri-&gt;uri_string() ?&gt;" /&gt;         in my view file
  
     $this-&gt;session-&gt;set_flashdata('errors', validation_errors());
     redirect($this-&gt;input-&gt;post('redirect')); 
  </code></pre>
  
  <p>In my view file:</p>
  
  <pre><code>   &lt;?php
  
      if ($this-&gt;session-&gt;flashdata('errors')){ //change!
      echo "&lt;div class='error'&gt;";
      echo $this-&gt;session-&gt;flashdata('errors');
      echo "&lt;/div&gt;";
      }
  
      ?&gt;
  </code></pre>
  
  <p>Thus I can pass validation error data through redirect from controller to previous page</p>