Advertisement
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{
- function __construct(){
- parent::__construct();
- }
- public function validate(){
- // grab user input
- $username = $this->input->post('username');
- $password = md5($this->input->post('password'));
- // Prep the query
- $this->db->where('nama_user', $username);
- $this->db->where('password_user', $password);
- // Run the query
- $query = $this->db->get('user');
- // Let's check if there are any results
- if($query->num_rows == 1)
- {
- // If there is a user, then create session data
- $row = $query->row();
- $data = array(
- 'nama_user' => $row->nama_user,
- 'password_user' => $row->password_user,
- );
- $this->session->set_userdata($data);
- return true;
- }
- // If the previous process did not validate
- // then return false.
- return false;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement