Welcome Guest, Not a member yet? Register   Sign In
updating on database with form validation
#1

(This post was last modified: 04-27-2017, 01:05 PM by ciadmin. Edit Reason: added code tags )

I have a form filled with inputs , wich i form validate them , i have a problem with two of them , 'matricule' and 'email' , in my callback function i set that if when of those tow exists in the table, it won't be no insert or update , so my problem is when i want to update other fields without changing these two , an error will be shown saying that the allready exists. Can u tell me please how to solve this problem
here is some code :
My controller function :

Code:
        public function unique_matricule($matricule) 
   {



 $verif=true;



$old_matricule = $this->etudiant_model->get_matricule($this->input->post('m'));

$all_matricules = $this->etudiant_model->get_all_matricules();



echo json_encode($old_matricule);





foreach ($all_matricules as $key) {



if ($key->matricule == $old_matricule) {

unset($all_matricules[$key]);

break;

}

}echo json_encode($all_matricules);



foreach ($all_matricules as $key) {





if($key->matricule == $matricule)

{

$verif = false ;

break;

}

}



if($matricule == $old_matricule || $verif==true)

{

return true;

}

else

{

return false;

}
after doing this , an error is shown wich tells me this "Illegal offset type in unset".

my $all_matricules array is this :[{"matricule":"123123"},{"matricule":"140273"},{"matricule":"231564"}]

So when i select the row that i want to modify , i want my code to delete its matricule from this array with unset function, can u tell me please what i have done wrong ?

Thank you!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB