在数据库中重新输入数据

I have this validation on my on-going system in which the scenario is like this:

If the employee is exist on designation 1 and branch 1 he/she could proceed to other designation 2 and branch 2 and so on. I have this code:

Here is on my view:

$emp_id = $this->input->post('emp_id');        
$position =$this->input->post('d_id');
$branch =$this->input->post('b_id');
$date1 =$this->input->post('datepicker');
$date2=$this->input->post('datepicker2');

This is on my Controller:

$sql_test = $this->db->select("employee_id, designation_id,branch_id")->from("tb_emp_record2")->where("employee_id", $emp_id)->get();

foreach($sql_test->result() as $val){

    $validate_employee = $val->employee_id;
    $validate_position = $val->designation_id;
    $validate_branch = $val->branch_id;
}

and here's my validation code sample:

if($validate_employee === $emp_id && $validate_position === $position && $validate_branch === $branch){

    redirect('Mainx/evaluation_form/' .$emp_id. '/Error1');
    //$this->load->view('evaluation');

}elseif($validate_employee === $position && $validate_employee === $branch){

    redirect('Mainx/evaluation_form/' .$emp_id. '/Error2');

}elseif($position === $validate_employee && $validate_position === $emp_id){

    redirect('Mainx/evaluation_form/' .$emp_id. '/Error3');

}elseif($position === $validate_position && $emp_id === $validate_employee){

    redirect('Mainx/evaluation_form/' .$emp_id. '/Error4');

}elseif($branch === $validate_branch && $emp_id === $validate_employee){

    redirect('Mainx/evaluation_form/' .$emp_id. '/Error5');

}elseif($validate_employee === $date1 && $validate_employee === $date2){

    redirect('Mainx/evaluation_form/' .$emp_id. '/Error6');

}else{

    $this->db->insert('tb_emp_record2', $insert_eval);
        redirect('Mainx/evaluation_form/' .$emp_id. '/success' );
}

At first it was working after an success attempt as I go on to check for an error it insert an invalid entry.

Hey guys I finally answered my question. Yes, I am very happy and here's my working code:

$employee_id = array();
            $designation_id = array();
            $branch_id = array();
            $date_start = array();
            $date_end = array();
            //$sql_test = $this->db->select("emp_record_id,employee_id, designation_id,branch_id,date_start,date_end")->from("tb_emp_record2")->where("employee_id", $emp_id)->get();

            $this->db->select("*");
            $this->db->from("tb_emp_record2");
            $this->db->join("tb_designation", "tb_emp_record2.designation_id = tb_designation.designation_id", "inner");
            $this->db->join("tb_branch", "tb_emp_record2.branch_id = tb_branch.branch_id", "inner");
            $this->db->where("employee_id", $emp_id );
            $sql_test = $this->db->get();

            foreach($sql_test->result() as $val){

                $employee_id[] = $val->employee_id;
                $designation_id[] = $val->designation_id;
                $branch_id[] = $val->branch_id;
                $date_start[] = $val->date_start;
                $date_end[] = $val->date_end;                               

            }


                if(in_array($position, $designation_id) && in_array($branch, $branch_id) && in_array($date1, $date_start) && in_array($date2, $date_end)){

                    redirect('Mainx/evaluation_form/' .$emp_id. '/Error1');

                }
                else {

                    $this->db->insert('tb_emp_record2', $insert_eval);
                    redirect('Mainx/evaluation_form/' .$emp_id. '/success' );
                }