CodeIgniter Forums
How to build an admin panel [SOLVED] - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: General Help (
+--- Thread: How to build an admin panel [SOLVED] (/thread-67391.html)

How to build an admin panel [SOLVED] - kirasiris - 02-16-2017

Hello guys, I've been wondering what is the right way to start the admin panel.

I mean I already have the admin pages, etc; but what I want is to block the access to the public, is there a way to do it by htaccess, or can you explain me how to do some type of login. 

And I think is going to be little bit hard, because as stated above all admin pages are done, but I never though of dong a login panel before accessing to it. 

Here is my controller (Admin/ index function):
PHP Code:
public function index(){
$data['title'] = 'Admin Panel';
$data['blog'] = $this->blog_model->get_blog();
$data['portfolio'] = $this->portfolio_model->get_portfolio();


that's all what I got, I did not even create an admin model, or anything related to it.Neither a table in the databse.)

This is my dashboard:
[Image: 7b2d7ac45e0abdc28057cd7997d79ee2.jpg]

As I said the dashboard is completely done, with all the functions working, I just need to block the access

RE: How to build an admin panel - stebo - 02-17-2017


there are several login tutorials available. Just search for e. g. codeigniter 3 login tutorial and you will find a bunch of nice descriptions how to realize a login for your page.

With these basics you are able to wrap up your admin sites into a closed area.

The easiest way is to set some $_SESSION data like "login = TRUE" after the login was successfull.
Then you implement a check in every controller within your admin area, if user is logged in and has access to this controller. If not, redirect him to login page.

I hope this will help you ;-)

Best regards from Germany

RE: How to build an admin panel - ignitedcms - 02-17-2017

The best and easiest permission class I found was:

Which I've integrated into ignited cms and ignited cms pro.

RE: How to build an admin panel - Avenirer - 02-17-2017

Try Ion_auth. It's quite basic and does the job well.

RE: How to build an admin panel - kirasiris - 02-18-2017

Well this is what I got so far, I do nt want to create another views,etc. I just wat to block all the IP address, or set one Io to have the accesss to these pages. And to do that I put this in my __construct

       public function __construct()

//// Block access to admin pages ////

           //Here you check ip allowed or not
           if (!in_array($this->input->ip_address(), array('','2602:306:bd06:7270:fcdd:74c5:c591:dc4')))
              // Either show 404

              // OR redirect somewhere else


I found ths tutorial on Stackoverflow, byt apprently I have to create an input as called "ip_address" and I do not know where should I create it, but as I said before I would like to avoid the creating of new controller, views/models etc.

RE: How to build an admin panel - ivantcholakov - 02-18-2017

"I do Front-End development most of the time, but I trying to get more into being a full-stack developer, so I'm now learning all what I need to do!"

"I just want to do this..., I want to avoid that..." - Why do you waste people's time? Just do what you intend to do.