[eluser]Kiran Dangol[/eluser]
Hello everybody,
I am having problem in redirecting the urls in admin panel. I have created a genesis_panel folder inside controller folder. There are two files inside genesis_panel/folder:
1. login.php
2. dashboard.php
Code of login.php is given below:-
Quote:<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Login extends CI_Controller {
function __construct(){
parent::__construct();
if(!($this->session->userdata('user_log'))){
redirect('genesis_panel/login/index');
}else{
redirect('genesis_panel/dashboard/index');
}
}
public function index()
{
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run() === FALSE){
$data['username']=mysql_real_escape_string($this->input->post('username'));
$data['password']=mysql_real_escape_string($this->input->post('password'));
$this->session->set_userdata('user_log',$this->input->post('username'));
redirect('genesis_panel/dashboard/index');
}
$this->load->view('genesis-panel/login');
}
function change_password(){
die('hello');
}
}
Now what the problem is that, I was unable to redirect from the constructor.
Both the urls given same error and says "The page isn't redirecting properly".
But I was able to redirect form the login/index when the form is submitted by removing redirect code of constructor.
One thing,I have declared in routes like
$route['genesis_panel'] = "genesis_panel/login";
Please anyone help me to get out of this problem.