CodeIgniter:验证表单未重置输入

I Hope my question is not wrong(not easy for you). to the point...
I have form with validation (check to database MySQL). like this

controller

$ck['no_ktp'] = $this->input->post('no_ktp');
$cek = $this->app_model->getSelectedData("biodata_karyawan",$ck);
if($cek->num_rows()>0)
{
    $this->session->set_flashdata('flash_messages', 'ERROR : No KTP sudah ada di data karyawan..!!!');
    redirect( base_url() . 'karyawan/tambah/' . $site );                    
}
else
{

this code is work with appear messages 'ERROR : No KTP sudah ada di data karyawan..!!!' but the form input will be reset. so I must input this form again.

Question
How to still appear the messages but the field not reset ?

thanks before for your time

This happens because of the redirect. Basically, it reloads the page. What you can do, is after the form is validated, place the inputed values in session variables. If the form is validated correctly and no errors appear, then unset the session variables, else, redirect and on the view page, by default, in each input, place what you have in the session var. kind of like this:

echo '<input type="text" name="some_name" value="'.(isset($_SESSION['some_name']) ? $_SESSION['some_name'] : '').'" />

Hope it helps!
Keep on coding
Ares.

Maybe the best solution is load the view which contains the form and passing all the post array to reload inputs.

$ck['no_ktp'] = $this->input->post('no_ktp');
$cek = $this->app_model->getSelectedData("biodata_karyawan",$ck);
if($cek->num_rows()>0)
{
    $this->session->set_flashdata('flash_messages', 'ERROR : No KTP sudah ada di data karyawan..!!!');
    //redirect( base_url() . 'karyawan/tambah/' . $site );
    $data['form_contents'] = $this->input->post();
    $this->load->view('form_view', $data);
}
else
{

And then, again in the form view, load inputs calling:

<input type="text" name="whatever" value="<?php echo $form_contents['whatever'];?>" />

Hope this helps.

EDIT 1: My fail naming $form_contents in view and controller. Previously was wrong, now is ok.

$ck['no_ktp'] = $this->input->post('no_ktp');
$cek = $this->app_model->getSelectedData("biodata_karyawan",$ck);
if($cek->num_rows()>0)
{
    $this->session->set_flashdata('flash_messages', 'ERROR : No KTP sudah ada di data karyawan..!!!');
    redirect( base_url() . 'karyawan/tambah/' . $site );      
    exit;              
}
else
{