我尝试验证我的表单,但它总是返回 FALSE。表单填充 POST 变量,设置了验证配置,但它不起作用。我尝试了一切,现在我卡住了。也许你的眼睛发现了错误。
这是我的控制器:
public function new_pass()
{
$code = mysql_real_escape_string($this->uri->segment(3));
$this->load->model('forgot_password_model');
if($this->forgot_password_model->check_code($code))
{
if($this->input->post('submit'))
{
$this->new_pass_validation();
}
else
{
$this->new_pass_form();
}
}
else
{
redirect('welcome');
}
}
private function new_pass_validation()
{
$this->load->library('form_validation');
var_dump($this->form_validation->run('forgot_password/new_pass'));
var_dump($this->input->post());
if ($this->form_validation->run() === FALSE)
{
// print_r('dump' . validation_errors());
$this->new_pass_form();
}
else
{
}
}
配置/form_validation:
$config = array(
'forgot_password/new_pass' => array(
array(
array(
'field' => 'password',
'label' => lang('default_jelszo'),
'rules' => 'trim|required|min_length[5]|max_length[32]'
),
array(
'field' => 'repassword',
'label' => lang('default_jelszo_megerosites'),
'rules' => 'trim|required|matches[password]|callback_password_hash'
),
)
),
);
和观点:
<section id="content">
<a id="logo" href=""></a>
<?=validation_errors(); ?>
<div class="formwrapp">
<form action="<?=site_url() . $this->uri->uri_string(); ?>" method="post">
<h3>Forgot password</h3>
<ul>
<li>Pass</li>
<li><input type="password" value="" name="password" /></li>
<li>Repass</li>
<li><input type="password" value="" name="repassword" /></li>
<li> </li><li><input id="login" type="submit" value="Submit" name="submit" /></li>
</ul>
</form>
</div>
</section>