$this->form_validation->set_rules('email', 'Email', 'required|trim|valid_email|is_unique[users.email]');
$this->form_validation->set_rules('password', 'Password', 'required|trim|min_length[8]|max_length[20]');
$this->form_validation->set_rules('password', 'Confirm Password', 'required|trim|matches[password]');
$this->form_validation->set_message('is_unique', "That email address already exists.");
$this->form_validation->set_message('min_length[8]', "The password length is too short.");
我可以知道为什么密码部分不起作用,但电子邮件部分有效。
每当我尝试输入长度小于8的密码时,表单仍会提交,信息仍会插入我的数据库
答案 0 :(得分:0)
密码字段名称不唯一。
$this->form_validation->set_rules('password', 'Password', 'required|trim|min_length[8]|max_length[20]');
$this->form_validation->set_rules('password', 'Confirm Password', 'required|trim|matches[password]');
将其更改为:
$this->form_validation->set_rules('password', 'Password', 'required|trim|min_length[8]|max_length[20]');
$this->form_validation->set_rules('confirm_password', 'Confirm Password', 'required|trim|matches[password]');