如何防止Code Igniter中的SQL注入?

时间:2017-03-10 11:30:10

标签: php codeigniter

我的程序无法进行sql注入的安全扫描。以下是我将数据插入数据库的功能之一。请建议我应该如何修改我的代码以防止SQL注入。 提前谢谢。

public function set_timeline() {
    $this->load->helper('url');
    $this->load->helper('form');
    $data = array(
        'fiid' => $this->input->post('fiid'),
        'project_id' => $this->input->post('project_id'),
        'testing' => $this->input->post('testing'),
        'start_date' => $this->input->post('start_date'),
        'end_date' => $this->input->post('end_date'),
        'description' => $this->input->post('description'),
        'project_progress' => $this->input->post('project_progress'),
        'tester' => $this->input->post('tester'),
        'status' => $this->input->post('status')
    );

    $this->db->insert('timeline',$data);

    if ($this->db->affected_rows() > 0) {
        echo '<script>alert("Timeline Added Successfully"); window.history.back(); </script>';
    }
    else {  
        echo '<script>alert("Timeline already exist!"); window.history.back();</script>';
    }                       
}

0 个答案:

没有答案