Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if (! defined('BASEPATH')) exit ('NO direct script access allowed');
- class Login_model extends CI_Model{
- public function login($user_id){
- $CI = & get_instance();
- $CI->session->set_userdata('logged', $userdata);
- }
- public function logout(){
- $CI = & get_instance();
- $CI->session->sess_destroy();
- }
- public function validate($nama, $password){
- $query = $this->db->get_where('login', array('nama' => $nama));
- $cek = $query->num_rows();
- if($cek != 0){
- foreach($query->result() as $row):
- $client['id_client'] = $row->id_user;
- $client['nama'] = $row->nama;
- $client['password'] = $row->password;
- endforeach;
- $passmd5 = md5($password);
- if($passmd5 == $client['password']){
- $this->login($client['id_client']);
- return true;
- }else{
- return false;
- }
- }else{
- return false;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment