You've already forked codeigniter_test2
first commit
This commit is contained in:
65
application/controllers/barang_controller.php
Normal file
65
application/controllers/barang_controller.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
class barang_controller extends CI_Controller{
|
||||
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
$this->load->helper(array('form', 'url'));
|
||||
$this->load->library('form_validation');
|
||||
$this->load->model('barang_model');
|
||||
}
|
||||
|
||||
function barang()
|
||||
{
|
||||
if( $this->session->userdata('isLoggedIn') ) {
|
||||
$this->load->model('barang_model');
|
||||
$data['judul'] = 'Tampil barang';
|
||||
$data['daftar_barang'] = $this->barang_model->get_barang_all();
|
||||
$this->load->view('HalamanUtama', $data);
|
||||
} else {
|
||||
redirect('user_controller/login');
|
||||
}
|
||||
}
|
||||
|
||||
function add_Barang()
|
||||
{
|
||||
$data['judul'] = 'Tambah Barang';
|
||||
$this->load->view('add_barang',$data);
|
||||
}
|
||||
|
||||
function simpan_barang()
|
||||
{
|
||||
$this->barang_model->simpan_barang();
|
||||
redirect('barang_controller/barang','refresh');
|
||||
}
|
||||
|
||||
function edit($id)
|
||||
{
|
||||
$data['judul']='Update Barang';
|
||||
$data['edit']=$this->barang_model->update_barang($id);
|
||||
$this->load->view('edit_barang', $data);
|
||||
}
|
||||
|
||||
function simpan_update_barang()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
$nama = $this->input->post('nama_barang');
|
||||
$harga = $this->input->post('harga');
|
||||
|
||||
$data['judul'] = 'Update Data Codeigniter';
|
||||
$this->load->model('user_model');
|
||||
$data['edit'] = $this->barang_model->simpan_update_barang($id, $nama, $harga);
|
||||
echo ("<SCRIPT LANGUAGE='JavaScript'>
|
||||
window.alert('Succesfully Updated')
|
||||
</SCRIPT>");
|
||||
redirect('barang_controller/barang','refresh');
|
||||
|
||||
}
|
||||
function delete($id)
|
||||
{
|
||||
$id = $this->barang_model->delete_barang($id);
|
||||
|
||||
redirect('barang_controller/barang');
|
||||
}
|
||||
|
||||
}
|
10
application/controllers/index.html
Normal file
10
application/controllers/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
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);
|
||||
}
|
||||
}
|
||||
?>
|
35
application/controllers/welcome.php
Normal file
35
application/controllers/welcome.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Welcome extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Index Page for this controller.
|
||||
*
|
||||
* Maps to the following URL
|
||||
* http://example.com/index.php/welcome
|
||||
* - or -
|
||||
* http://example.com/index.php/welcome/index
|
||||
* - or -
|
||||
* Since this controller is set as the default controller in
|
||||
* config/routes.php, it's displayed at http://example.com/
|
||||
*
|
||||
* So any other public methods not prefixed with an underscore will
|
||||
* map to /index.php/welcome/<method_name>
|
||||
* @see http://codeigniter.com/user_guide/general/urls.html
|
||||
*/
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('welcome_message');
|
||||
}
|
||||
|
||||
public function login()
|
||||
{
|
||||
$data['judul'] = 'Halaman Login';
|
||||
$this->load->view('login', $data);
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
Reference in New Issue
Block a user