title: How to Reset form on successful registration only, yet keep content when when submission fails
body: <pre><code>&lt;h3 class="text-upper background-blue1 top-margin-reg"&gt; Register now&lt;/h3&gt;
  &lt;h5 class="text-grey padding-bottom-20 padding-top-10"&gt;Don't have an Account?&lt;/h5&gt;
  &lt;form action="&lt;?=site_url('home/register')?&gt;" method="post" class="border-left "&gt;
      &lt;?php if(isset($message)) '&lt;span class="text-success txt-upper"&gt;'. $message . '&lt;/span&gt;';?&gt;
      &lt;table class="table " style="margin-left: 11%;"&gt;
          &lt;tr class="col-md-5"&gt;
              &lt;td class="login-textfield"&gt;
                  &lt;input type="text" id="firstname" class="background-grey" placeholder="First name" name="firstname" value="&lt;?php echo set_value('firstname')?&gt;" required id="firstname" /&gt;
                  &lt;?php echo form_error( 'firstname'); ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="col-md-5"&gt;
              &lt;td class="login-textfield"&gt;
                  &lt;?php echo form_input( 'lastname',set_value( 'lastname'), 'placeholder="Last name", class="background-grey" id="lastname" required id="lastname"')?&gt;
                  &lt;?php echo form_error( 'lastname'); ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="col-md-5"&gt;
              &lt;td class="login-textfield"&gt;
                  &lt;?php echo form_input( 'phone',set_value( 'phone'), ' placeholder="Phone Number", class="background-grey" id="phone" required id="phone"')?&gt;
                  &lt;?php echo form_error( 'phone'); ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="login-textfield"&gt;
                  &lt;?php echo form_input( 'username',set_value( 'username'), ' placeholder="Username", id="user_name" class="background-grey" required id="user_name"')?&gt;
                  &lt;?php echo form_error( 'username'); ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="login-textfield"&gt;
                  &lt;?php echo form_input( 'email',set_value( 'email'), ' placeholder="Email", class="background-grey" id="email" required id="email"')?&gt;
                  &lt;?php echo form_error( 'email'); ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="login-textfield"&gt;
                  &lt;input type="password" name="password" placeholder="Password" class="background-grey" id="password" required id="password" |matches[password_confirm]/&gt;
                  &lt;?php echo form_error( 'password'); ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="login-textfield"&gt;
                  &lt;input type="password" name="password_confirm" placeholder="Confirm Password" class="background-grey" id="password_confirm" required id="password_confirm" /&gt;
                  &lt;?php echo form_error( 'password_confirm'); ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="login-textfield text-grey radio-pad"&gt;Gender
                  &lt;input type="radio" name="gender" value="male" checked/&gt;male
                  &lt;input type="radio" name="gender" value="female" /&gt;female&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="login-textfield text-center padding-top-10"&gt;
                  &lt;input class="btn btn-primary btn-width-120 button-pos" type="submit" value="Register" name="register" id="form" style="width: 121%;" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I am sorry but the code elements were not working for this. The above text is my code, I want to reset the form when submission is successful but keep the content in it when there are validation errors.</p>
  
  <p>Controller Code:-</p>
  
  <pre><code>public function register(){
      // Set up the form
      $rules = $this-&gt;user_m-&gt;rules_admin;
      $rules['password']['rules'] .= '|required';
      $this-&gt;form_validation-&gt;set_rules($rules);
      $this-&gt;form_validation-&gt;set_message('required', 'This field is required');
      $this-&gt;form_validation-&gt;set_error_delimiters('&lt;small class="text-danger txt-upper"&gt;', '&lt;/small&gt;');
  
      // Process the form
      if ($this-&gt;form_validation-&gt;run() == TRUE) 
      {
          if($this-&gt;user_m-&gt;add_user())
          {
              $this-&gt;data['message']= "You are registered successfully. Please login" ;
  
  
          }
  
          else
          {
              $this-&gt;data['message']= "Failed to register";
          }
  
      }
                  $this-&gt;data['subview'] = 'home/login';
                  $this-&gt;load-&gt;view('_layout_main_1', $this-&gt;data);
              //  $this-&gt;load-&gt;view('home/login', $this-&gt;data);
          }
  </code></pre>