73 thoughts on “Admin Panel with Login in CodeIgniter”

  1. Hey

    I try all your instructions but when i try admin page it give me error that page not find. So any further instruction for this. Thanks

    1. plz make sure u’ve managed ur .httaccess file or route.php file inside config/ folder.
      same problem i’v faced but .htaccess worked for me…..
      if u dnt have .htacces file plz google once and create a .httaccess file

  2. do you know the exact solution of this .httaccess in codeigniter because i test on wamp , i enable all of modules also add code in htaccess but its not working still, any suggestions you have.

    1. Did u put the script as below in your .htaccess file?

      RewriteEngine on
      RewriteBase /

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule .* your_project_name/index.php/$1 [PT,L]

  3. The download link displays 404 error. The page cant be found. Kindly mail me the adminPanelWithLogin.zip file. Thanks in anticipation.

    1. 1. Locate the file config.php in /application/config/ directory
      2. define(‘VIEWBASE’,’http://localhost/example/application/views/’); in that file.

      Thanx
      Dev

  4. Howdy, i read your blog from time to time and i own a similar one and i was just curious
    if you get a lot of spam comments? If so how do you protect against it, any plugin or anything you can recommend?

    I get so much lately it’s driving me crazy so any support is very much appreciated.

  5. this is happened when login
    A PHP Error was encountered

    Severity: Notice

    Message: Undefined variable: data

    Filename: admin/home.php

    Line Number: 13
    plz help to solve this issue i am tryin but not getting proper way..

  6. David you can define your data value using
    $data = “”;
    if($this->session->userdata(‘xxxxxxxxx’)){
    $query = $this->session->all_userdata();
    $data[‘yyy’] = $query[‘xxxxx’];
    $data[‘yyy’] = $query[‘xxxxx’];
    $data[‘yyy’] = $query[‘xxxxx’];
    }
    $this->viewForm($data);

    Please replace the xxx and yyy with name define in your code. It works for me.

  7. dear sir,

    i extract your files and replace the all folder like controllers with your folder controllers and same as views and models , after that i run the change the routes file with the default controllers index , but this is giving the error with “The page was you requested was not found “please help me with all steps .

  8. Hi, i have succeed to run this trial apps, but the style won’t show eventhough i have defined the ‘viewbase’ code in config file. And i try to change the url src to be my link project refer to the css file something like this ‘http://localhost/project_name/application/views/admin/css/bootstrap.css’ but it still won’t show the style from the css files.

    Maybe you can kindly tell me what’s wrong with this?

    Thank you

  9. Hello,

    I downloaded the files and placed them on the specified locations. I used the RewriteRule provided by you earlier in this topic. I used “$route[‘admin/(:any)’] = “admin/$1″;” in routes.php, but still when I try to open the admin it gives me 404 error. Please let me know where I am lacking…?

    Thanks

  10. Hi,

    I cracked my last step. But now I stuck in next hurdle. When I input the login credentials (admin, admin_123) in Login Area.
    When I hit the login Button it remains on the same Login Window Page with redirected url in the bar to “admin/home” and it gives me the error msg: “Invalid username and/or password”.

    I would req. you to provide the solution ASAP.

    Thanks

    1. Dear Mayank,

      Please check whether you have created your mysql table / database. If yes, please check whether you are entering the right credentials.

      Thanks

  11. Hi Dev,

    Thank you for the reply. I have created the database and credentials are correct. I used the same code provided above to create the database table. Do I need to create a session table…?

    Thanks

          1. Dear Admin,

            Yes I am working the same url pattern and yes it’s working, It is showing the login screens, but the problem occurs when I hit the login button.

            Thanks

  12. Dear Admin,

    Please suggest the solution to my above mentioned query.

    public function process(){
    // Load the model
    //$this->load->model(‘login_model’);
    $this->load->model(‘admin/admin_model’);
    // Validate the user can login
    $result = $this->admin_model->validate();
    // Now we verify the result
    if(! $result){
    // If user did not validate, then show them login page again
    $msg = ‘Invalid username and/or password.’;
    $this->index($msg);
    }else{
    echo “Loading…”;
    // If user did validate,
    // Send them to members area
    redirect(base_url().’index.php/admin/home/’);

    }
    }

    Both the conditions (If, else) are working from this code. I am using user as “admin ” and Password as “admin_123″

    1. Please check what $result is printing using print_r. I am not sure what mistake you are making at your code. You can debug the code instead. You are very near to your goal.

      Thanks
      Dev

      1. I tried using Print_r. Validation process is working fine. However I haven’t changed the code it’s same as I downloaded from here.

        Here both If and else condition is working like when I input user as “admin ” and Password as “admin_123″, it redirects to home in URL but it remains on the same page (login), as well it prints the message “Invalid username and/or password”.

        Thanks

        1. There is a redirect() function in the controller home.php. This function is missing at your side. Please replace it with any redirect code.

          Thanks
          Dev

          1. controller home.php

            check_isvalidated();
            }
            public function index()
            {
            $this->viewForm($data);
            }

            private function check_isvalidated(){
            if(! $this->session->userdata(‘validated’)){
            redirect(‘admin/login’);
            }
            }

            private function viewForm($data=”){
            $this->load->view(‘admin/header’);
            $this->load->view(‘admin/sidebar’);
            $this->load->view(‘admin/home’, $data);
            $this->load->view(‘admin/footer’);
            }

            }
            ?>

            where should i use the redirect function. I tried it at different locations but didn’t get the success.

            In my last post I provided the code of process() here I am not getting it how both the conditions are working.

    1. It shows 1 when I use user as “admin ” and Password as “admin_123″ and blank if I input wrong credentials.

      I am using below mentioned routes, please let me know if I can do something here

      $route[‘admin’] = ‘admin/login’;
      $route[‘admin/(:any)’] = ‘admin/home/$1’;
      $route[‘admin/(:any)’] = ‘admin/login/process’;

  13. I have used the following routes in my routes.php

    $route[‘default_controller’] = “home”;
    $route[‘404_override’] = ”;

    Thanks
    Dev

    1. If I use this route

      $route[‘default_controller’] = “home”;
      $route[‘404_override’] = ”;

      It shows “404 Page Not Found”.

      But when I use

      $route[‘default_controller’] = ‘admin/home’;
      $route[‘404_override’] = ”;

      Its shows the home directly without login page, with the following error.

      A PHP Error was encountered

      Severity: Notice

      Message: Undefined variable: data

      Filename: admin/home.php

      Line Number: 13

      Thanks

  14. I am using $route[‘default_controller’] for frontend as well. Below is the route.php code which I am using for frontend and admin part.

    $route[‘admin’] = ‘admin/login’;
    $route[‘admin/(:any)’] = ‘admin/home/$1’;
    $route[‘admin/(:any)’] = ‘admin/login/process’;

    $route[‘news/create’] = ‘news/create’;
    $route[‘news/(:any)’] = ‘news/view/$1’;
    $route[‘news’] = ‘news’;
    $route[‘default_controller’] = ‘pages/view’;
    $route[‘(:any)’] = ‘pages/view/$1’;

    Thanks

  15. i have a suggestion for the developer to save support time for you what you dont offer the admin app for download already installed in a working codeigniter demo site plus the sql file and thats it.
    thanks.


  16. hi admin..
    i'm gettnig error in VIEWBASE. and home page it showing list footer and all in center of page it showing empty box. how to solve it??

    thank you.!

  17. Oh my goodness! Incredible article dude! Thanks,
    However I am experiencing troubles with your RSS.
    I don’t know the reason why I cannot join it. Is there anyone
    else getting the same RSS issues? Anybody who knows the solution will you kindly respond?

    Thanks!!

  18. Please help me downloading the files or mail me the files. Not able to download it from the given link.
    Thankyou.

  19. Hello, I am using your admin login on mysite,Everything is okay but I am unable to login using this code.I think session is not working .When I comment this section $this->check_isvalidated(); ,It’s login otherwise its not working.Please help me to fix this issues.

  20. Thank you a lot for sharing this with all folks you actually understand
    what you are talking approximately! Bookmarked.
    Kindly additionally visit my site =). We could have a hyperlink alternate contract between us

Leave a Reply

Your email address will not be published. Required fields are marked *