Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Check For Duplicate on Edit Function
#1

Check For Duplicate on Edit Function

Currently my DB table

    USERDB
    userId userName userPassword userEmail userAddress userPhone


What I want

> Allow to check on "userName" duplication" and if "userName" return
> true , then it allow to edit other textfield.

Problem Met:

> When i did not change anything on my "userName" field , and i edited
> userEmail, it will always return FALSE due to my "userName" is
> duplicate with current DB data.


    $checkvalidation = $this->userdb->UsernameDuplicatechecking($userName);
    if($checkvalidation == TRUE){
    $this->userdb->updateUser($userName,$userEmail,$userAddress,$userPhone,$id);
    }else{
      $this->session->set_flashdata('errormessage', 'Duplicate');
      redirect("User/EditUserAccount/$id");
      }

Update Model Code

    public function updateUser($userName,$userEmail,$userAddress,$userPhone,$id);
    {
    $UserArray = array(
    'userName' => $userName,
    'userEmail' => $userEmail,
    'userAddress' => $userAddress,
    'userPhone' => $userPhone,
      );
   
   
        $this->db->set($UserArray);
    $this->db->where('userId',$id);
    $this->db->update('USERDB');
    }
Reply


Messages In This Thread
Codeigniter Check For Duplicate on Edit Function - by incognitorecon - 08-02-2019, 08:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB