개발 Q&A

제목 post 값 model 전달 문의드립니다~~
카테고리 PHP
글쓴이 미스힐링 작성시각 2020/03/02 17:25:00
댓글 : 2 추천 : 0 스크랩 : 0 조회수 : 7830   RSS

$data['users'] = array(           

'email' => $this->input->post('email'),           

'password' => $this->input->post('password')       

);

users배열에 form에서 넘어온 이메일,패스워드값을 넣고

$this->Login_model->check_users($data);

 

로그인 모델 페이지로 전달을 하였는데 받는쪽에서 계속 에러가 납니다..

 

public function check_users($data) {

    $this->db->where('email', $data->email);

    $this->db->where('password', $data->password);

    return $this->db->count_all_results($this->table);

}

 

혹시 $data['users'] 이런식으로 해서 넣은 값을 모델에서 받을때 어떤식으로 받아야되는지 조언 부탁드립니다~~~

 다음글 크롬브라우져에서 SameSite Warning에 대한 ... (1)
 이전글 views url 문의드립니다~~ (2)

댓글

곰멍 / 2020/03/02 17:32:35 / 추천 0

보내주는 $data는 배열 형태인데, 사용하는 $data는 객체 형식이라 없는 데이터를 불러와서 에러가 발생하시는 것 같습니다.

check_users 메소드 $data 부분을 이렇게 변경해보시기 바랍니다.

 

public function check_users($data) {

    $this->db->where('email', $data['users']['email']);

    $this->db->where('password', $data['users']['password']);

    return $this->db->count_all_results($this->table);

}

미스힐링 / 2020/03/02 17:40:01 / 추천 0
오 해결했습니다~~감사합니다!!