Postingan lainnya
Undefined property: dashboard::$m_data
A PHP Error was encountered Severity: Notice
Message: Undefined property: Dashboard::$M_data
Filename: controllers/Dashboard.php
Line Number: 58
Backtrace:
File: C:\xampp\htdocs\website_ci\application\controllers\Dashboard.php Line: 58 Function: _error_handler
File: C:\xampp\htdocs\website_ci\index.php Line: 315 Function: require_once
controllers/Dashboard.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Dashboard extends CI_Controller {
public function ganti_password_aksi() {
// form validasi
$this->form_validation->set_rules('password_lama','Password Lama','required');
$this->form_validation->set_rules('password_baru','Password Baru','required|min_length[8]');
$this->form_validation->set_rules('konfirmasi_password','Konfirmasi Password Baru','required|matches[password_baru]');
// cek validasi
if($this->form_validation->run() != false){
// menangkap data dari form
$password_lama = $this->input->post('password_lama');
$password_baru = $this->input->post('password_baru');
$konfirmasi_password = $this->input->post('konfirmasi_password');
// cek kesesuaian password lama dengan id pengguna yang sedang login dan password lama
$where = array(
'pengguna_id' => $this->session->userdata('id'),
'pengguna_password' => md5($password_lama)
);
$cek = $this->m_data->cek_login('pengguna', $where)->num_rows();
// cek kesesuaikan password lama
if($cek > 0){
// update data password pengguna
$w = array(
'pengguna_id' => $this->session->userdata('id')
);
$data = array(
'pengguna_password' => md5($password_baru)
);
$this->m_data->update_data($where, $data, 'pengguna');
// alihkan halaman kembali ke halaman ganti password
redirect('dashboard/ganti_password?alert=sukses');
}else{
// alihkan halaman kembali ke halaman ganti password
redirect('dashboard/ganti_password?alert=gagal');
}
}else{
$this->load->view('dashboard/v_header');
$this->load->view('dashboard/v_ganti_password');
$this->load->view('dashboard/v_footer');
}
}
}
?>
models/m_data
<?php
class M_data extends CI_Model{
function cek_login($table,$where){
return $this->db->get_where($table,$where);
}
// fungsi untuk mengupdate atau mengubah data di database
function update_data($where,$data,$table){
$this->db->where($where);
$this->db->update($table,$data);
}
}
?>
Salahnya dimana ya? saya cari pertanyaan sama disini ada tapi juga belum berhasil seperti jawaban suruh lihat config/autoload.php
$autoload['libraries'] = array('database','session','form_validation');
terus apa ya yang salah?
Ini potongan line 58
$cek = $this->m_data->cek_login('pengguna', $where)->num_rows();
1 Jawaban:
Jawaban Terpilih
Model M_data nya belum di load
<pre> <?php defined('BASEPATH') OR exit('No direct script access allowed');
class Dashboard extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('m_data'); } } </pre>
Semoga berhasil