|
$config['enable_query_strings'] = TRUE;这个设置成True,form_open('c=users&m=adduser'),执行下面的代码可以显示表单验证提示。
但$config['enable_query_strings'] = FALSE;form_open('/users/adduser')为什么就不出来验证提示啊,高手指点一下。
代码如下:
class Users extends CI_Controller {
public function index()
{
$this->load->view('welcome_message');
}
public function register()
{
$data['main_content'] = 'register';
$this->load->view('include/template',$data);
}
public function adduser()
{
//$this->lang->load('form_validation', 'chinese');
$this->load->library('form_validation');
$this->form_validation->set_rules('u_email', '电子邮箱', 'required|valid_email|is_unique[users.u_email]');
$this->form_validation->set_rules('u_pwd', '账号密码', 'required');
$this->form_validation->set_rules('re_pwd', '确认密码', 'required|matches[password]');
$this->form_validation->set_rules('u_nick', '账号昵称', 'required|is_unique[users.u_nick]');
$this->form_validation->set_rules('u_sex', '用户性别', 'required');
$this->form_validation->set_rules('province', '所在省市', 'required');
$this->form_validation->set_rules('city', '所在市区', 'required');
$this->form_validation->set_rules('code', '验 证 码', 'required|exact_length[4]');
if($this->form_validation->run() == FALSE)
{
echo ($this->form_validation->run() == FALSE).'----';
print_r(validation_errors());
//echo $this->validation->error_string();
//$this->load->view('register');
$this->register();
}else{
$this->load->model(user);
$this->user->adduser();
}
}
}
请高手指点!!! |
|