Promo Lebaran, Kelas Online CODEPOLITAN Cukup Bayar Setengah Harga KLAIM PROMO

database error disaat akan login

Ditanyakan pada tanggal 21 May 2020 oleh Haris Pratama Edit  Hapus  Tandai Selesai  Tandai 

Error Number: 1146

Table 'code_cishop.login' doesn't exist

SELECT * FROM login WHERE email = '[email protected]' AND is_active = 1

Filename: C:/xampp/htdocs/cishop/system/database/DB_driver.php

Line Number: 691

BUAT KOMENTAR

1 JAWABAN / 0 KOMENTAR

User avatar
Ahmad Oriza menjawab pada tanggal 22 May 2020 Jadikan Jawaban Terbaik  Edit  Hapus  Ubah ke Komentar 

Sepertinya salah tabel kak.

Itu karena ada source code yang salah.

Coba cek controller Login.php :

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Login extends MY_Controller 
{

    public function __construct()
    {
        parent::__construct();
        $is_login   = $this->session->userdata('is_login');

        if ($is_login) {
            redirect(base_url());
            return;
        }
    }

    public function index()
    {
        if (!$_POST) {
            $input  = (object) $this->login->getDefaultValues();
        } else {
            $input  = (object) $this->input->post(null, true);
        }

        if (!$this->login->validate()) {
            $data['title']  = 'Login';
            $data['input']  = $input;
            $data['page']   = 'pages/auth/login';

            $this->view($data);
            return;
        }

        if ($this->login->run($input)) {
            $this->session->set_flashdata('success', 'Berhasil melakukan login!');
            redirect(base_url());
        } else {
            $this->session->set_flashdata('error', 'E-Mail atau Password salah atau akun Anda sedang tidak aktif!');
            redirect(base_url('login'));
        }
    }

}

/* End of file Login.php */

Lalu cek model Login_model.php :

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Login_model extends MY_Model 
{

    protected $table = 'user';

    public function getDefaultValues()
    {
        return [
            'email'     => '',
            'password'  => '',
        ];
    }

    public function getValidationRules()
    {
        $validationRules = [
            [
                'field' => 'email',
                'label' => 'E-Mail',
                'rules' => 'trim|required|valid_email'
            ],
            [
                'field' => 'password',
                'label' => 'Password',
                'rules' => 'required'
            ]
        ];

        return $validationRules;
    }

    public function run($input)
    {
        $query  = $this->where('email', strtolower($input->email))
                    ->where('is_active', 1)
                    ->first();

        if (!empty($query)) {
            $sess_data = [
                'id'        => $query->id,
                'name'      => $query->name,
                'email'     => $query->email,
                'role'      => $query->role,
                'is_login'  => true,
            ];
            $this->session->set_userdata($sess_data);
            return true;
        }

        if (!empty($query) && hashEncryptVerify($input->password, $query->password)) {
            $sess_data = [
                'id'        => $query->id,
                'name'      => $query->name,
                'email'     => $query->email,
                'role'      => $query->role,
                'is_login'  => true,
            ];
            $this->session->set_userdata($sess_data);
            return true;
        }

        return false;
    }

}

/* End of file Login_model.php */

Lalu cek juga file application/core/MY_Model.php :

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class MY_Model extends CI_Model 
{

    protected $table    = '';
    protected $perPage  = 5;

    public function __construct()
    {
        parent::__construct();

        if (!$this->table) {
            $this->table = strtolower(
                str_replace('_model', '', get_class($this))
            );
        }
    }

    /**
     * Fungsi Validasi Input
     * Rules: Dideklarasikan dalam masing-masing model
     *
     * @return void
     */
    public function validate()
    {
        $this->load->library('form_validation');

        $this->form_validation->set_error_delimiters(
            '<small class="form-text text-danger">', '</small>'
        );
        $validationRules = $this->getValidationRules();

        $this->form_validation->set_rules($validationRules);

        return $this->form_validation->run();
    }

    /**
     * Seleksi data per-kolom
     * Chain Method
     *
     * @param [type] $columns
     * @return void
     */
    public function select($columns)
    {
        $this->db->select($columns);
        return $this;
    }

    /**
     * Mencari suatu data pada kolom tertentu dengan data yang sama
     * Chain Method
     * @param [type] $column
     * @param [type] $condition
     * @return void
     */
    public function where($column, $condition)
    {
        $this->db->where($column, $condition);
        return $this;
    }

    /**
     * Mencari suatu data pada kolom tertentu dengan data yang mirip
     * Chain Method
     * @param [type] $column
     * @param [type] $condition
     * @return void
     */
    public function like($column, $condition)
    {
        $this->db->like($column, $condition);
        return $this;
    }

    /**
     * Mencari suatu data selanjutnya pada kolom tertentu dengan data yang mirip
     * Chain Method
     * @param [type] $column
     * @param [type] $condition
     * @return void
     */
    public function orLike($column, $condition)
    {
        $this->db->or_like($column, $condition);
        return $this;
    }

    /**
     * Menggabungkan Table yang berelasi yang memiliki foreign key id_namatable
     * Chain Method
     * @param [type] $table
     * @param string $type
     * @return void
     */
    public function join($table, $type = 'left')
    {
        $this->db->join($table, "$this->table.id_$table = $table.id", $type);
        return $this;
    }

    /**
     * Mengurutkan data dari hasil query dan kondisi
     * Chain Method
     * @param [type] $column
     * @param string $order
     * @return void
     */
    public function orderBy($column, $order = 'asc')
    {
        $this->db->order_by($column, $order);
        return $this;
    }

    /**
     * Menampilkan satu data dari hasil query dan kondisi
     * Hasil Akhir Chain Method
     * @return void
     */
    public function first()
    {
        return $this->db->get($this->table)->row();
    }

    /**
     * Menampilkan banyak data dari hasil query dan kondisi
     * Hasil Akhir Chain Method
     * @return void
     */
    public function get()
    {
        return $this->db->get($this->table)->result();
    }

    /**
     * Menampilkan nilai jumlah data dari hasil query dan kondisi
     * Hasil Akhir Chain Method
     * @return void
     */
    public function count()
    {
        return $this->db->count_all_results($this->table);
    }

    /**
     * Menyimpan data baru ke dalam suatu tabel
     *
     * @param [type] $data
     * @return void
     */
    public function create($data)
    {
        $this->db->insert($this->table, $data);
        return $this->db->insert_id();
    }

    /**
     * Mengubah data yang ada pada suatu tabel dengan data baru
     *
     * @param [type] $data
     * @return void
     */
    public function update($data)
    {
        return $this->db->update($this->table, $data);
    }

    /**
     * Menghapus suatu data dari hasil query dan kondisi
     * 
     * @return void
     */
    public function delete()
    {
        $this->db->delete($this->table);
        return $this->db->affected_rows();
    }

    /**
     * Menentukan Limit data untuk ditampilkan
     *
     * @param [type] $page
     * @return void
     */
    public function paginate($page)
    {
        $this->db->limit(
            $this->perPage,
            $this->calculateRealOffset($page)
        );

        return $this;
    }

    /**
     * Menggantikan offset dengan nilai sesuai halaman
     *
     * @param [type] $page
     * @return void
     */
    public function calculateRealOffset($page)
    {
        if (is_null($page) || empty($page)) {
            $offset = 0;
        } else {
            $offset = ($page * $this->perPage) - $this->perPage;
        }

        return $offset;
    }

    /**
     * Membuat Pagination dengan style bootstrap 4
     *
     * @param [type] $baseUrl
     * @param [type] $uriSegment
     * @param [type] $totalRows
     * @return void
     */
    public function makePagination($baseUrl, $uriSegment, $totalRows = null)
    {
        $this->load->library('pagination');

        $config = [
            'base_url'          => $baseUrl,
            'uri_segment'       => $uriSegment,
            'per_page'          => $this->perPage,
            'total_rows'        => $totalRows,
            'use_page_numbers'  => true,

            'full_tag_open'     => '<ul class="pagination">',
            'full_tag_close'    => '</ul>',
            'attributes'        => ['class' => 'page-link'],
            'first_link'        => false,
            'last_link'         => false,
            'first_tag_open'    => '<li class="page-item">',
            'first_tag_close'   => '</li>',
            'prev_link'         => '&laquo',
            'prev_tag_open'     => '<li class="page-item">',
            'prev_tag_close'    => '</li>',
            'next_link'         => '&raquo',
            'next_tag_open'     => '<li class="page-item">',
            'next_tag_close'    => '</li>',
            'last_tag_open'     => '<li class="page-item">',
            'last_tag_close'    => '</li>',
            'cur_tag_open'      => '<li class="page-item active"><a href="#" class="page-link">',
            'cur_tag_close'     => '<span class="sr-only">(current)</span></a></li>',
            'num_tag_open'      => '<li class="page-item">',
            'num_tag_close'     => '</li>',
        ];

        $this->pagination->initialize($config);
        return $this->pagination->create_links();
    }
}

/* End of file MY_Model.php */
BUAT KOMENTAR