在输入数据中要执行的安全操作


Security things to do in input data

我在CodeIgniter框架中有一个网站构建。该网站包含许多用于不同目的的表格。我将这些表格直接提交给控制器功能。

  1. 在通过模型将其保存到数据库之前,我应该在此输入中应用哪些内容?

  2. 如果我直接发送此数据而不执行任何操作,将会产生什么安全风险?

你需要

使用form_validationhttps://ellislab.com/codeigniter/user-guide/libraries/form_validation.html

最好的方法是为每个字段设置规则喜欢这个

$this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');
        $this->form_validation->set_rules('username', 'Username', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required');
        $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
        $this->form_validation->set_rules('email', 'Email', 'required');
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('myform');
        }
        else
        {
            $this->load->view('formsuccess');
        }

而且您不需要使用任何特殊的转义

或者尝试了解如何在CodeIgniter中使用PDO。

http://codebyjeff.com/blog/2013/03/codeigniter-with-pdo