You've already forked codeigniter_test2
first commit
This commit is contained in:
62
application/controllers/user_controller.php
Normal file
62
application/controllers/user_controller.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
class User_controller extends CI_Controller{
|
||||
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
$this->load->model('user_model');
|
||||
}
|
||||
|
||||
function insert_user()
|
||||
{
|
||||
$data['judul'] = 'Insert Data User';
|
||||
$this->load->view('user', $data);
|
||||
}
|
||||
|
||||
function simpan_user()
|
||||
{
|
||||
$this->user_model->simpan_user();
|
||||
$data['notifikasi'] = 'Data berhasil disimpan';
|
||||
$data['judul']='Insert Data Berhasil';
|
||||
}
|
||||
|
||||
function login()
|
||||
{
|
||||
$data['judul'] = 'Halaman Login';
|
||||
$this->load->view('login', $data);
|
||||
}
|
||||
|
||||
function validasi()
|
||||
{
|
||||
$user = $this->input->post('username');
|
||||
$pass = $this->input->post('password');
|
||||
$cek = $this->user_model->login($user,$pass);
|
||||
//echo $cek;
|
||||
if ($cek)
|
||||
{
|
||||
$session = array(
|
||||
'username' => $user,
|
||||
'isLoggedIn' => TRUE
|
||||
);
|
||||
|
||||
$this->session->set_userdata($session);
|
||||
redirect('barang_controller/barang');
|
||||
echo $this->session->all_userdata();
|
||||
}
|
||||
else {
|
||||
|
||||
$this->load->view('login');
|
||||
//echo 'salah';
|
||||
}
|
||||
}
|
||||
function logout()
|
||||
{
|
||||
$array_items = array('username' => '', 'isLoggedin' => false);
|
||||
$this->session->unset_userdata($array_items);
|
||||
$this->session->sess_destroy();
|
||||
//$session_destroy();
|
||||
$data['judul'] = 'Halaman Login';
|
||||
$this->load->view('login', $data);
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user