<?php

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

class Myaccount extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->isLoggedIn();
        $this->load->model('model_app');
        $this->isLoggedIn();
    }

    function isLoggedIn() {
        $isLoggedIn = $this->session->userdata('isLoggedIn');
        if ($isLoggedIn == false) {
            $this->session->set_flashdata('message_red_password', 'LOGIN DULUUUU CUY !');
            redirect('admin/loginpage');
        }
    }

    private $table = 'user';
    private $control = 'admin/myaccount';
    private $folder_view = 'super/myaccount';
    private $pk = 'id';

    public function index() {
        renderSuper($this->folder_view);
    }
    
    function updateAccount(){
        $username = $this->input->post("new_username");
        if(!empty($username)){
            $key['id'] = 1;
            $password = $this->input->post("new_password");
            $data = array(
                'username' => $username,
                'password' => md5($password)
            );
            $this->model_app->insertData($this->table, $data);
            $this->session->set_flashdata('message_green_password', 'Data Berhasil Diperbarui');
            redirect('admin/dashboard');
        }
    }

}

/* End of file myaccount.php */
/* Location: ./application/controllers/myaccount.php */