title: How to get the success message in the same page after submitting the form?
body: <p>I'm trying to display a success and error message in the same page. What do i need to change?</p>
  
  <p>The form is to send the data to the database and then show a success message in the same page, then redirect to another page. I've tried changing the ID value in the form and the java script, i still get the same results, the data is sent to the database, it redirects to another page, but it doesn't show the success message before redirecting.</p>
  
  <p>Controller: </p>
  
  <pre><code>public function register_ajax() { 
      //form validation rules
      $this-&gt;form_validation-&gt;set_rules('org_name', 'Organisation Name', 
       'trim|required');
      $this-&gt;form_validation-&gt;set_rules('email', 'Email', 
       'trim|required|valid_email|is_unique[new_church.email]',
          array('is_unique' =&gt; "This email address is already registered 
          with this application.")
      );
      $this-&gt;form_validation-&gt;set_rules('password', 'Your Password', 
      'trim');
      $this-&gt;form_validation-&gt;set_rules('c_password', 'Confirm Password', 
      'trim|required|matches[password]',
          array(
              'matches' =&gt; 'Password does not match'
          )
      );
      if ($this-&gt;form_validation-&gt;run())  {   
          $this-&gt;registration_model-&gt;update_church(); //insert the data 
          into db
          echo 1;
          redirect(site_url('registration/payment'));
      } else { 
          echo validation_errors();
      }
  }
  </code></pre>
  
  <p>Model: </p>
  
  <pre><code>public function update_church() { 
      $org_name = ucwords($this-&gt;input-&gt;post('org_name', TRUE)); 
      $email = $this-&gt;input-&gt;post('email', TRUE); 
      $password = ucfirst($this-&gt;input-&gt;post('password', TRUE));
      $c_password = ucfirst($this-&gt;input-&gt;post('c_password', TRUE));
      $data = array (
          'org_name' =&gt; $org_name,
          'email' =&gt; $email,
          'password' =&gt; $password,
          'c_password' =&gt; $c_password,
      );
      $this-&gt;db-&gt;insert('new_church', $data);
  
      //email admins
      //$this-&gt;notify_admins($name, $email, $subject, $message);
  }
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>//Registration
  $('#registration_form').submit(function(e) {
      e.preventDefault();
      var form_data = $(this).serialize();
      $.ajax({
          url: base_url + 'registration', 
          type: 'POST',
          data: form_data, 
          success: function(msg) {
              if (msg == 1) {
                  $('#status_msg').html('&lt;div class="alert alert-success 
                  text-center"&gt; Success.&lt;/div&gt;').fadeIn( 'fast' );
                  $('#registration_form')[0].reset(); //reset form fields 
              } else {
                  $('#status_msg').html('&lt;div class="alert alert-danger 
                  text-center"&gt;' + msg + '&lt;/div&gt;').fadeIn( 'fast' ).delay( 
                  30000 ).fadeOut( 'slow' );
              }
          }
      });
  });
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;?php 
      $form_attributes = array("id" =&gt; "registration_form");
      echo form_open('registration/register_ajax', $form_attributes); ?&gt;
  
  
      &lt;div class="login100-form validate-form"&gt;       
  
        &lt;div class="wrap-input100 validate-input" data-validate = "First 
         name is required"&gt;
          &lt;label class="form_header"&gt;Organisation Name&lt;/label&gt;
          &lt;input class="input100" type="text" name="org_name" value="&lt;?php 
           echo set_value('org_name'); ?&gt;" required/&gt;
          &lt;span class="focus-input100"&gt;&lt;/span&gt;
        &lt;/div&gt;
  
        &lt;div class="wrap-input100 validate-input" data-validate = "Valid 
          email is required: ex@abc.xyz"&gt;
          &lt;label class="form_header"&gt;Your Work Email Address&lt;/label&gt;
          &lt;input class="input100" type="email" name="email" value="&lt;?php 
            echo set_value('email'); ?&gt;" required/&gt;
          &lt;span class="focus-input100"&gt;&lt;/span&gt;
        &lt;/div&gt;
  
        &lt;div class="wrap-input100 validate-input" data-validate = "Password 
          is required"&gt;
          &lt;label class="form_header"&gt;Your Password&lt;/label&gt;
          &lt;input class="input100" type="password" name="password" value="&lt;? 
           php echo set_value('password'); ?&gt;" required/&gt;
          &lt;span class="focus-input100"&gt;&lt;/span&gt;
        &lt;/div&gt;
  
        &lt;div class="wrap-input100 validate-input" data-validate = "Confirm Password"&gt;
  
          &lt;label class="form_header"&gt;Confirm Password&lt;/label&gt;
          &lt;input class="input100" type="password" name="c_password" value="&lt;?php echo set_value('c_password'); ?&gt;" required/&gt;
          &lt;span class="focus-input100"&gt;&lt;/span&gt;
        &lt;/div&gt;
  
        &lt;div class="text-center p-t-12"&gt;
          &lt;p&gt;By clicking the button below, you agree to StreamApp's terms of acceptable use&lt;/p&gt;
        &lt;/div&gt;
  
        &lt;div class="m-t-20"&gt;  
            &lt;div id="status_msg"&gt;&lt;/div&gt;
        &lt;/div&gt;
  
        &lt;div class="container-login100-form-btn"&gt;
          &lt;button class="login100-form-btn"&gt;  NEXT &lt;/button&gt;
        &lt;/div&gt;
  
      &lt;/div&gt;
  
        &lt;?php echo form_close(); ?&gt;
  </code></pre>
  
  <p>I expect a success message to appear before redirecting to another page</p>