douying2243 2017-03-10 11:30
浏览 149

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

My program failed the security scannning for sql injection. The following is one of my function to insert data into db.. Please advice how should I modify my code to prevent SQL injection. Thanks in advance.

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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
    • ¥15 MCNP里如何定义多个源?
    • ¥20 双层网络上信息-疾病传播
    • ¥50 paddlepaddle pinn
    • ¥20 idea运行测试代码报错问题
    • ¥15 网络监控:网络故障告警通知
    • ¥15 django项目运行报编码错误
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏