• Adi

    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

    • admin

      Deaer Adi, You might have been missing the clean URL part. So, please try this link to access the admin page: http://localhost/your_project/index.php/admin.
      Hope this may work.

      Regards
      Admin

      • Paul Chater

        Will this work with a HMVC approach?

        • admin

          Dear Paul, This is done for plain CI. You can further modify the code according to your needs.

      • sush

        i am beginner in ci , i am facing similar problem, i have tried http://localhost/your_project/index.php/admin. also but there is no change….it would be very helpful for your further guidance

  • arnezt

    where is the MY_Controller file? refers to “class Home extends MY_Controller”

    • admin

      Dear arnezt,

      Pleae rename MY_Controller to CI_Controller, that will work.

      Thanx,
      Admin

  • huseyn

    Thank you very much! I created that.
    And due to your example I increase my knowledge in mvc.

  • I’m trying using your script and its goes page not found..i’ve tried http://localhost/app/index.php/admin
    page not found

    • admin

      Dear Syafiq, something might have gone wrong with your code. Please recheck.

    • 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

  • thank you for share.. This really helped me

  • I try to use the latest version is not successful ci, ci weve uses the version number?
    beg in reply to this comment ?

    • admin

      I am not sure about the latest version of the CI. We use earlier versions. But I hope there might not be any kind of issues with the latest version. Please visit http://ellislab.com/codeigniter for further information.

  • excellent information hope to get more in future.

  • netcat

    i try to go to index.php/admin page but i redirect to index of my page and noting show to me.

    so what can i do????

    • admin

      Did you put the files at correct location?

  • Fahad

    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.

    • admin

      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]

  • tunde

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

  • admin

    Dear Tunde,

    You can Download the file from the same link.

    Thanx.

  • parmar prahlad bhagvanji bhai

    Hello sir,

    I have extracted the files as per you said.
    I put different files as following
    controller/admin
    view/admin
    models/admin

    When I run using as this path : http://localhost/prahladandhari/avangatecms/admin
    I get following errors :
    Object not found. suggest solution.
    Thanks.

  • Val

    In order to use the Session class you are required to set an encryption key in your config file.

    • admin

      Yes Val, Its for your convinience. Its a better option if you use an encryption key.

  • hani

    error with style, exactly in VIEWBASE
    that in view files.

    how i can define it and where?

    • admin

      VIEWBASE is defined in /application/config/config.php
      Enjoy coding.

      Thanx,
      Admin

    • FR

      Class ‘MY_Model’ not found in your download folder

      • admin

        Dear FR,
        Make MY_Model to CI_Model, this will definitely work.

        Thanks,

  • sara

    how can define VIEWBASE in config ??
    $config[‘VIEWBASE’]=”http://localhost/example/” is it correct??

    • admin

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

      Thanx
      Dev

  • naqqashrana

    Respected sir when i try to access admin/index page through this url http://localhost/codeigniter/admin.
    But there is showing welcome page and if i want to get http://localhost/codeigniter/index.php/admin still there is showing same welcome page.

  • 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.

  • david

    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..

  • David,
    You have to define the value of your $data, then pass it like this: $this->viewForm($data);

  • 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.

  • Raj Kumar Bhardwaj

    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 .

  • Raj Kumar Bhardwaj

    what is code i can write for admin path and front end path in to the routs.php?

  • Nicola Oda

    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

  • Mayank

    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

  • Mayank

    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

    • Dev

      Dear Mayank,

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

      Thanks

      • Mayank

        Dear Admin,

        What should I do to get it done, login part. I just followed the same code provided by you.

        Thanks

  • Mayank

    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

    • admin

      Dear Mayank,

      There is no need to create any session table.

      Thanks
      Dev

      • Mayank

        Dear Admin,

        What should I do to get it done, login part. I just followed the same code provided by you.

        Thanks

        • admin

          Dear Mayank,

          Did you tried http://localhost/your_project/index.php/admin? If this is working you have to configure clean URL on your server.

          Thanks
          Dev

          • Mayank

            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

  • Mayank

    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″

    • Ram

      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

      • Mayank

        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

        • admin

          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

          • Mayank

            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.

  • admin

    Please send me the result after print_r($result).

    Thanks

    • Mayank

      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’;

  • admin

    I have used the following routes in my routes.php

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

    Thanks
    Dev

    • Mayank

      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

  • Mayank

    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

  • Mayank

    Dear Admin,

    Any solution of my query…?

    Thanks

  • 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.

  • sathish


    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.!

    • admin

      Dear Satish,

      Sorry for late reply. Can you please send a screenshot of the output at nomeasdev@gmail.com? This will help me understanding your issue more clearly.

      Thanks

  • shimii

    i am a codeigniter beginner so what is the database name

  • shimii

    i am getting error viewbase how ca solve this

  • Your method of describing everything in this piece of writing is actually nice, every one
    can effortlessly understand it, Thanks a lot.

  • 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!!

  • I got this web site from my pal who shared with me on the topic of this web page and now this time I am visiting this web page and reading very
    informative posts here.

  • Nish

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

  • Nish

    Please send the zip file by mail. Not able to download file.
    Thanx in advance.

  • globalwebmatrix

    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.