我很遗憾再次提问,我已经检查了有关此问题的答案,但我真的无法解决这个问题。请帮忙。谢谢!
自动加载:$autoload['helper'] = array('form', 'url');
查看:
<?php
echo form_open('members/update_password_validation/'.$id, array('role' => 'form'));
echo validation_errors();
echo '<div class="form-group">';
echo form_label('Password:', 'password');
echo form_password(array('name' => 'password', 'id' => 'password', 'class' => 'form-control'));
echo '</div>';
echo '<div class="form-group">';
echo form_label('Confirm Password:', 'cpassword');
echo form_password(array('name' => 'cpassword', 'id' => 'cpassword', 'class' => 'form-control'));
echo '</div>';
echo '<div class="form-group">';
echo form_submit(array('name' => 'update_password_submit', 'value' => 'Update Password', 'class' => 'btn btn-default'));
echo '</div>';
echo form_close();
?>
控制器:
class Members extends CI_Controller {
public function index()
{
//some code here
}
public function update_password_validation($id)
{
$this->load->library('form_validation');
$this->form_validation->set_rules('password', 'Password', 'required|trim');
$this->form_validation->set_rules('cpassword', 'Confirm Password', 'required|trim|matches[password]');
if ($this->form_validation->run())
{
//success
}
else
{
//fail
}
}
}
为什么$this->form_validation->run()
总是返回false?
答案 0 :(得分:-1)
if ($this->form_validation->run() == FALSE)
{
//success
}
else
{
//fail
}