CI 묻고 답하기

제목 답변부탁드립니다..^^
글쓴이 영등포 작성시각 2011/08/26 14:33:34
댓글 : 3 추천 : 0 스크랩 : 0 조회수 : 15971   RSS

입력폼을 간단하게  만들어 테스트해보면서
xss처리를 해봣는데 이런식으로 하면 돼나여?
//view
    <td  height="36" bgcolor="white" width="549">
    <p> <input type="text" name="name" size="29" ></p>
    </td>
    <td  height="36" bgcolor="white" width="549">
    <p> <input type="text" name="title" size="29" ></p>
    </td>
//controler
  //실행
  function bbs_confirm(){
   $this->load->library('form_validation');
   $this->load->model('model');

   $name=$this->form_validation->set_rules('name', 'Name', 'trim|required|xss_clean');
   $rank=$this->form_validation->set_rules('rank', 'Rank', 'trim|required|xss_clean');

    $this->input->post('name', TRUE);
    $this->input->post('rank', TRUE);

   $data['result'] = $this->model->insert_entry();
   redirect('board/list/');
  }


//model
 function insert_entry()
    {
        $this->name = $_POST['name'];
  $this->rank = $_POST['rank'];
        $this->db->insert('tbl_menu', $this);
    }
 

 다음글 FTP를 이용하여 내 컴퓨터에서 다른서버로 막바로 업로... (2)
 이전글 페이지네이션 질문이요~ (2)

댓글

변종원(웅파) / 2011/08/26 15:16:39 / 추천 0
  $_POST['name'] <- 쓰지 않는 것이 좋습니다.

컨트롤러에서 form validation과 $this->input->post('val, true)로 보안에 대해 중복선언까지 하셨는데
실제 모델에서  $_POST['name'] 이렇게 써버리면 효과가 없습니다.

제 경우엔 컨트롤러에서 모델로 데이터를 넘김때 $_POST로 전체를 넘기고
모델에서 각 데이터 처리할때 xss_clean($_POST['val']) 형태로 사용하고 있습니다.
영등포 / 2011/08/26 16:16:41 / 추천 0
넵..감사합니다.
한대승(불의회상) / 2011/08/29 15:00:49 / 추천 0
 @웅파 ㅋㅋㅋㅋㅋ 귀차니즘 종결자...