【发布时间】:2016-01-25 21:38:40
【问题描述】:
我目前正在学习框架“CodeIgniter”。但是我的表单验证有问题。首先,让我向您展示我的观点:
<form method="post" action="connexion">
<label for="pseudo">Pseudo : </label>
<input type="text" name="pseudo" value="" />
<label for="mdp">Mot de passe :</label>
<input type="password" name="mdp" value="" />
<input type="submit" value="Envoyer" /></form>
我的控制器:
public function connexion()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('pseudo', '"user name"', 'trim|required|min_length[5]|max_length[52]|alpha_dash|encode_php_tags|xss_clean');
$this->form_validation->set_rules('mdp', '"password"', 'trim|required|min_length[5]|max_length[52]|alpha_dash|encode_php_tags|xss_clean');
if($this->form_validation->run())
{
$this->load->view('connexion_ok');
}
else
{
$this->load->view('form');
}
}
当我在 set_rules() 中删除控制器中的“xss_clean”过滤器时,它运行良好,表单有效。如果存在“xss_clean”,则它不起作用,它会进入 else。我在输入中不使用特殊字符,只使用字母。
在设置中,我将其设为 true:$config['global_xss_filtering'] = TRUE;
我在某处读到“xss_clean”过滤器没用。我还能用什么?也许是帮手或别的什么? 谢谢
【问题讨论】:
-
验证!它在其他地方
-
XSS 保护功能默认关闭。要打开此功能,您只需将全局配置(即 system/application/config/config.php)设置为
$config['global_xss_filtering'] = TRUE;
标签: php codeigniter model-view-controller view controller