sistem registrasi user

bro gimana caranya ketika waktu user register terus login harusnya di nonaktifkan dulu nah nanti biar adminnya yg aktifkan itu gimana caranya

register.php

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

class Register extends CI_Controller {

    function __construct(){
        parent::__construct();
        $this->load->library(array('form_validation'));
        $this->load->helper(array('url','form'));
        $this->load->model('m_login'); //call model
    }

    public function index() {



        $this->form_validation->set_rules('uname', 'USERNAME','required');
        $this->form_validation->set_rules('pass','PASSWORD','required');
        $this->form_validation->set_rules('nama', 'NAME','required');
        $this->form_validation->set_rules('level','level','required');




        if($this->form_validation->run() == FALSE) {
            $this->load->view('v_register');
        }else{
            $data=array(

                'username' => $this->input->post('uname'),
                'password' => md5($this->input->post('pass')),
                'nama' => $this->input->post('nama'),
                'level' => $this->input->post('level'),
                'status' => 0

              );


            $this->m_login->daftar($data);

            $this->session->set_flashdata('keluar', 'AKUN BERHASIL DI TAMBAHKAN');

            $this->load->view('login');
        }
    }
}

login.php

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

class Login extends CI_Controller{

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

        $this->load->model('m_login'); //memasukkan file model m_login.php ke dalam controller
    }

    function index(){
        $session = $this->session->userdata('isLogin'); //mengabil dari session apakah sudah login atau belum
        if($session == FALSE){
            $this->load->view('login');
        }else{ //jika session true maka di redirect ke halaman dashboard
            redirect('lu/user');
        }
    }

    function do_login(){
        $username = $this->input->post("uname");
        $password = $this->input->post("pass");

        $cek = $this->m_login->cek_user($username,md5($password)); //melakukan persamaan data dengan database

        if(count($cek) == 1){ //cek data berdasarkan username &amp; pass
            foreach ($cek as $cek) {
                    $level = $cek['level']; //mengambil data(level/hak akses) dari database
            }

            $this->session->set_userdata(array(
                    'isLogin'   => TRUE, //set data telah login
                    'uname'  => $username, //set session username
                    'lvl'      => $level, //set session hak akses
                    'status'      => 0, //set session hak akses


            ));

            redirect('Lu/user','refresh');  //redirect ke halaman dashboard
        }else{ //jika data tidak ada yng sama dengan database
            echo "<script>alert('Gagal Login!')</script>";
            redirect('login','refresh');
        }
    }
}
avatar ahmadjaki_google
@ahmadjaki_google

3 Kontribusi 0 Poin

Diperbarui 4 tahun yang lalu

Tanggapan

file model-nya mana?

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban