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.