Example #1
0
 function modify_pwd()
 {
     $this->load->library('form_validation');
     //验证
     $validation = array(array('field' => 'oldpwd', 'label' => '旧密码', 'rules' => 'required|callback_oldpwd_check'), array('field' => 'newpwd', 'label' => '新密码', 'rules' => 'required'), array('field' => 'reqpwd', 'label' => '确认密码', 'rules' => 'required|matches[newpwd]'));
     $this->form_validation->set_rules($validation);
     //设置验证
     //设置验证消息
     $this->form_validation->set_message('required', '%s不能为空!');
     $this->form_validation->set_message('oldpwd_check', '%s验证失!');
     $this->form_validation->set_message('matches', '%s与%s不匹配!');
     $this->form_validation->set_error_delimiters('<span class="round alert label">', '</span>');
     //修改错误提示定界符
     //表单提交验证
     if ($this->form_validation->run() === FALSE) {
         $data['title'] = '管理员修改密码';
         $this->load->view('templates/header', $data);
         $this->load->view('templates/top_navbar');
         $this->load->view('user/modify_pwd', $data);
         $this->load->view('templates/footer');
     } else {
         //验证成功是显示的消息
         $data = array('password' => md5($this->input->post('newpwd')));
         $this->admin_model->update($_SESSION['auth_admin'], $data);
         show_message($this, get_message_data('修改密码', '密码修改成功,下次登录时请使用新密码!', 0, current_url(), 3));
     }
 }
Example #2
0
File: Login.php Project: skyling/CI
 /**
  * 登录首页
  */
 public function index()
 {
     //判断是否登录,登陆后跳转至index/index
     if (isset($_SESSION['auth_admin']) && $_SESSION['auth_admin'] > 0) {
         redirect('index/index');
     }
     $this->load->library('form_validation');
     $validation = array(array('field' => 'username', 'label' => '用户名', 'rules' => 'required'), array('field' => 'password', 'label' => '密码', 'rules' => 'required|callback_pwd_check'));
     $this->form_validation->set_rules($validation);
     $this->form_validation->set_message('required', '%s不能为空!');
     $this->form_validation->set_message('pwd_check', '%s验证错误!');
     $this->form_validation->set_error_delimiters('<span class="round alert label">', '</span>');
     //修改错误提示定界符
     if ($this->form_validation->run() === FALSE) {
         $data['title'] = '管理员登录';
         $data['foundation_dir'] = config_item('foundation_dir');
         $this->load->view('login/index', $data);
     } else {
         show_message($this, get_message_data('后台管理系统', '登录成功!', 0, 'index/index', 3));
     }
 }