Welcome Guest, Not a member yet? Register   Sign In
Required File Not Working properly !
#1

[eluser]osama[/eluser]
Hi, friends
i have two simple pages admin_check.php and dashboard.php
I'm using the admin check file to protect my admin pages so i put a very simple code in it to know if the user logged in or not then I'm using this file ( admin_check) in other files to do the log in check process but it's not working when i require it in other files

This is admin_check code :

Code:
<?php
class Admin_check extends CI_Controller {
    function index()
{
  if (!$this->tank_auth->is_logged_in()) {
   redirect('/auth/login/');
  } else {
   $user_id = $this->tank_auth->get_user_id();
   $username = $this->tank_auth->get_username();
            echo"Welcome ". $username ." Your ID is ". $user_id ." .";
  }
}
}
?>

and This is The dashboard Code :

Code:
<?php
require("admin_check.php");
class Dashboard extends CI_Controller {
    public function index()
    {
        echo"<h2> Here Are DashBoard !</h2>";
    }
?&gt;

Logically When i go to htttp://localhost/codeigniter/index.php/dashboard

it should redirect me to log in page But it doesn't so I'm Wondering what's Wrong ?:coolsmirk:
#2

[eluser]Clooner[/eluser]
You are overriding the index method! And this is not the preferred way to extend a controller. Please read http://ellislab.com/codeigniter/user-gui...aries.html especially the part about Extending Native Libraries. Go try that after reading the userguide and have another go at it.
#3

[eluser]solid9[/eluser]
try,
htttp://localhost/codeigniter/index.php/dashboard/admin_check/




Theme © iAndrew 2016 - Forum software by © MyBB