Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function add()
- {
- $this->load->library('form_validation');
- $this->load->helper('form');
- //neu ma co du lieu post len thi kiem tra
- if($this->input->post())
- {
- $this->form_validation->set_rules('name', 'Tên', 'required|min_length[8]');
- $this->form_validation->set_rules('username', 'Tài khoản đăng nhập', 'required|callback_check_username');
- $this->form_validation->set_rules('password', 'Mật khẩu', 'required|min_length[6]');
- $this->form_validation->set_rules('re_password', 'Nhập lại mật khẩu', 'matches[password]');
- //nhập liệu chính xác
- if($this->form_validation->run())
- {
- //them vao csdl
- $name = $this->input->post('name');
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $data = array(
- 'name' => $name,
- 'username' => $username,
- 'password' => md5($password)
- );
- if($this->admin_model->create($data))
- {
- //tạo ra nội dung thông báo
- $this->session->set_flashdata('message', 'Thêm mới dữ liệu thành công');
- }else{
- $this->session->set_flashdata('message', 'Không thêm được');
- }
- //chuyen tới trang danh sách quản trị viên
- redirect(admin_url('admin'));
- }
- }
- $this->data['temp'] = 'admin/admin/add';
- $this->load->view('admin/main', $this->data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement