title: The form values are not retained on wrong submission in codeigniter
body: <p>I am trying to keep form values on wrong submission i used set_value but still it's not working fine.</p>
  
  <p>I don't know exactly where i mistaken</p>
  
  <p>Here is my controller:</p>
  
  <pre><code> public function createOrgUsers() {
          //Validating Name Field
          $this-&gt;form_validation-&gt;set_rules(
                  'temp_username', 'Username', 'required|min_length[5]|max_length[12]|is_unique[users.username]', array(
              'required' =&gt; 'You have not provided %s.',
              'is_unique' =&gt; 'This %s already exists.'
                  )
          );
          $this-&gt;form_validation-&gt;set_rules('temp_firstname', 'First Name', 'required');
          $this-&gt;form_validation-&gt;set_rules('temp_lastname', 'Last Name', 'required');
          $this-&gt;form_validation-&gt;set_rules('temp_password', 'Password', 'required');
          $this-&gt;form_validation-&gt;set_rules('temp_confirm_password', 'Password Confirmation', 'required|matches[temp_password]');
          $this-&gt;form_validation-&gt;set_rules('temp_emailid', 'Email', 'required|valid_email|is_unique[users.email]');
  
          if ($this-&gt;form_validation-&gt;run() == FALSE) {
             // $this-&gt;session-&gt;set_flashdata('error', 'User not created.');
              redirect('Organisation/createNewuser');
          } else {
              //Setting values for tabel columns
  
              $data = array(
                  'username' =&gt; $this-&gt;input-&gt;post('temp_username'),
                  'firstname' =&gt; $this-&gt;input-&gt;post('temp_firstname'),
                  'lastname' =&gt; $this-&gt;input-&gt;post('temp_lastname'),
                  'email' =&gt; $this-&gt;input-&gt;post('temp_emailid'),
                  'password' =&gt; password_hash($this-&gt;input-&gt;post('temp_password'), PASSWORD_DEFAULT),
                  'userlevel' =&gt; '3',
                  'organisation_id' =&gt; $this-&gt;input-&gt;post('organisation_id'),
                  'timestamp' =&gt; time(),
                  'ip' =&gt; $this-&gt;input-&gt;ip_address(),
                  'status' =&gt; 1,
                  'regdate' =&gt; time()
              );
  
              //Transfering data to Model
              $this-&gt;Org_model-&gt;orgUsers($data);
              $this-&gt;session-&gt;set_flashdata('success', 'User created successfully.');
              //Loading View
              redirect('Organisation/editOrg');
          }
      }
  </code></pre>
  
  <p>Here is my view:</p>
  
  <pre><code>&lt;div class="panel-body"&gt;
              &lt;?php echo validation_errors(); ?&gt;
              &lt;form action="&lt;?php echo base_url(); ?&gt;Organisation/createOrgUsers" id="user-groups-create" class="form-horizontal" method="post"&gt;                                 
                   &lt;div id="infoMessage" class="error" &gt;&lt;?php echo $this-&gt;session-&gt;flashdata('message'); ?&gt;&lt;/div&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;label class="col-sm-4 control-label"&gt;Username : &lt;/label&gt;
                      &lt;div class="col-md-8"&gt;
                          &lt;input type="text" name="temp_username" class="form-control" value="&lt;?php echo set_value('temp_firstname'); ?&gt;" /&gt;
                      &lt;/div&gt;
                      &lt;?php echo form_error('temp_username', '&lt;span class="error"&gt;', '&lt;/span&gt;'); ?&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label class="col-sm-4 control-label"&gt;First Name : &lt;/label&gt;
                      &lt;div class="col-md-8"&gt;
  
                          &lt;input type="text" name="temp_firstname" class="form-control"  value="&lt;?php echo set_value('temp_firstname'); ?&gt;" /&gt;
                      &lt;/div&gt;
                       &lt;?php echo form_error('temp_firstname', '&lt;span class="error"&gt;', '&lt;/span&gt;'); ?&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label class="col-sm-4 control-label"&gt;Last Name : &lt;/label&gt;
                      &lt;div class="col-md-8"&gt;
                          &lt;input type="text" name="temp_lastname" class="form-control"  value="&lt;?php echo set_value('temp_lastname'); ?&gt;" /&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label class="col-sm-4 control-label"&gt;Password : &lt;/label&gt;
                      &lt;div class="col-md-8"&gt;
                          &lt;input type="text" name="temp_password" class="form-control"  value="&lt;?php echo set_value('temp_password'); ?&gt;" /&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label class="col-sm-4 control-label"&gt;Confirm Password : &lt;/label&gt;
                      &lt;div class="col-md-8"&gt;
                          &lt;input type="password" name="temp_confirm_password" class="form-control"  value="" /&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label class="col-sm-4 control-label"&gt;Email Id : &lt;/label&gt;
                      &lt;div class="col-md-8"&gt;
                          &lt;input type="text" name="temp_emailid" class="form-control" value="&lt;?php echo set_value('temp_emailid'); ?&gt;" /&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;div class="col-md-8 col-sm-offset-4"&gt;
                          &lt;input type="hidden" name="organisation_id" value="&lt;?php echo $orgName[0]['id']; ?&gt;"&gt;
                          &lt;button type="submit" value="submit" class="btn btn-primary form-control" id="submit"&gt;Submit&lt;/button&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/form&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>And i don't know why i couldn't able to see error messages on form submission for each field.i am trying to show error messages for each form field if user clicked on submit button with out giving any values.</p>
  
  <p>can anyone please help me where i did mistake</p>
  
  <p>Thanks in advance</p>