title: CodeIgniter - save method and redirects
body: <p>I have a page to manage courses, built with CI 3.  When the user hits the save button, the form is submitted to the <code>save</code> method.  My problem is how do I redirect the user to the previous page with the form populated with the data inserted?</p>
  <p>At the moment what's happening is that after submit, the save method loads the views of the <code>/new</code> page, and the URL stays as <code>/save</code> with the data populated.</p>
  <p>Already tried the redirect, but it loses the data the user had inserted.</p>
  <p>Here a snippet of my save method:</p>
  <pre><code>public function save()
  {
      $this-&gt;checkIsAdmin();
      $this-&gt;load-&gt;helper('form');
      $this-&gt;load-&gt;library('form_validation');
  
      $this-&gt;form_validation-&gt;set_rules('name', $this-&gt;lang-&gt;line('common_name'), 'required');
      if ($this-&gt;form_validation-&gt;run() === FALSE)
      {
          $this-&gt;feedback_message-&gt;create('Please check fields', 'error');
          $this-&gt;baseInfo['page_title'] =  &quot;Registar novo curso&quot;;
          $this-&gt;mybreadcrumb-&gt;add('Registar curso', base_url('course/new'));
          $data['schools'] = $this-&gt;School_model-&gt;listSchools();
  
          $this-&gt;load-&gt;view('web/top', $this-&gt;baseInfo);
          $this-&gt;load-&gt;view($this-&gt;templatesFolder.'tabs_start', array('courseId' =&gt; 0));
          $this-&gt;load-&gt;view($this-&gt;templatesFolder.'manage', $data);
          $this-&gt;load-&gt;view($this-&gt;templatesFolder.'tabs_end');
          $this-&gt;load-&gt;view('web/footer');
  
          /*redirect(&quot;/course/new&quot;, &quot;location&quot;);*/
      }else{
          $saved = $this-&gt;Course_model-&gt;saveCourse();
          if($saved){
              $this-&gt;feedback_message-&gt;create('Success', 'success');
          }else{
              $this-&gt;feedback_message-&gt;create('Error '.$_POST['name'], 'error');
          }
          redirect('course/');
      }
  }
  </code></pre>