2014-06-09 4 views
0

안녕하세요 저는 CodeIgniter에서 새로 왔으며 간단한 PHP 대시 보드를 만들고 있습니다. 이제 formvalidation에 갇혀 있습니다. 입력에 삽입하는 것과 같은 공격을 피하기 위해 특수 문자에서 양식 입력을 삭제하려고합니다.CodeIgniter PHP formvalidation 명확한 html 특수 문자

이 같은 형태를 갖는다 :

<?php echo form_open('thread/create'); ?> 

     <label>Nadpis</label> 
     <input type="text" id="title" name="row[title]" class="span12" placeholder=""> 
     <label>Slug (url friendly)</label> 
     <input type="text" id="slug" name="row[slug]" class="span12" placeholder=""> 
     <label>Text príspevku</label> 
     <textarea name="row_post[post]" id="firstpost" rows="8" class="span12"></textarea> 
     <input type="submit" name="btn-create" value="Vytvoriť tému"/> 
     </form> 

을 그리고 이것은 내 컨트롤러에 : 나는 그것은 특수 문자와 제목을 손질하지 않는 제목 <h1>big</h1>에 새 게시물을 만들 때

public function create() 
    { 
      $this->load->helper(array('form', 'url')); 
      $this->load->library('form_validation'); 
      $this->form_validation->set_rules('title', 'title-n', 'trim|required|xss_clean|htmlspecialchars'); 
...etc 
} 

h1입니다. 그래서 내가 뭘 잘못하고있는거야? 감사합니다, 그것은 html 태그 (PHP Documentation on htmlspecialchars)

를 제거하지 않는 개체를 HTML로 특수 문자를 변환합니다

답변

0

htmlspecialchars

이하지 왜 :

$_POST['title'] = strip_tags($_POST['title']); 

또는 당신은 모든이를 적용하려면 내 값 : $_POST

foreach($_POST as $key => $item){ 
    $_POST[$key] = strip_tags($item); 
}