-2

Severity: Notice

Message: Undefined index: password

Filename: models/userr.php

Line Number: 10

Backtrace:

File: C:\xampp\htdocs\cooladmin\application\models\userr.php Line: 10 Function: _error_handler

File: C:\xampp\htdocs\cooladmin\application\controllers\auth.php Line: 17 Function: login

File: C:\xampp\htdocs\cooladmin\index.php Line: 315 Function: require_once

class userr extends CI_Model {

public function login($post) 
{
    $this->db->select('*');
    $this->db->from('user');
    $this->db->where('username', $post['username']);
    $this->db->where('password', $post['password']);
    $query = $this->db->get();
    return $query;
}  

class auth extends CI_Controller {

public function login()
{
    $this->load->view('login');
}

public function process()
{
    $post = $this->input->post(null, TRUE);
    if(isset($post['login'])) {
        $this->load->model('userr');
        $query = $this->userr->login($post);
        if($query->num_rows() > 0) {
            echo "login berhasil !";
        } else {
            echo "login gagal !";
        }
    }
}

}

Rahul
  • 18,271
  • 7
  • 41
  • 60
  • 3
    Possible duplicate of ["Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" using PHP](https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined) – Jonnix May 30 '19 at 11:38

1 Answers1

0

use this:

$this->db->where('password', isset($post['password']) ? $post['password'] : '');

It just means the password has not been posted from the form

Jikiwiki
  • 115
  • 1
  • 8