코드이그나이터) 폼 검증

2020. 4. 20. 22:37PHP

반응형

참고 사이트: http://www.ciboard.co.kr/user_guide/kr/libraries/form_validation.html

 

$this->form_validation->set_rules(필드이름,알기쉬운이름,검사규칙);


*검사규칙: 
 1.값 반드시 존재-required
 

 2.패스워드 확인-required|matches[password]
 

 3.길이제한-required|min_length[5]|max_length[12]


 4.유효한이메일,유일값-required|vaild_email|is_unique[users.email]

 

 5.숫자인지,길이제한-numeric|max_length[3]|min_length[2]|required
 

 6.함수 사용
  $this->form_validation->set_rules('username','Kate', array('required', array($this->user_model, 'valid_username'));
 

 7.콜백함수(db필요시에 controller에 함수추가)-callback_callFn[$str]
  public function callFn($str){
   if($str=='test'){
     $this->form_validation->set_message('username_check', The {field} field can be the word "test"');
     return false;
   }else{
     return true;
   }

 }

반응형

'PHP' 카테고리의 다른 글

php) array_multisort: 배열 정렬하기  (0) 2020.05.13
php) debug 찍기  (0) 2020.04.20
php) 기본 함수  (0) 2019.11.24
php) curl  (0) 2019.11.24
php) session  (0) 2019.11.24