[eluser]Unknown[/eluser]
Hi,
I'm need some help as I've been working on an application in codeigniter and it is behaving strangely.
Code:
<?php
class Signup extends Controller {
function __construct(){
$this->is_logged_in();
}
function index() {
$this->load->view('signup_view');
}
function is_logged_in() {
$is_logged_in = $this->session->userdata('is_logged_in');
if(!isset($is_logged_in) || $is_logged_in != true)
{
echo ('This session is not logged in. Access Denied');
echo ('<br />');
echo anchor('login', 'Login', 'title="Login"');
die();
}
}
function new_user() {
$data = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'email' => $this->input->post('email'),
'address' => $this->input->post('address'),
'city' => $this->input->post('city'),
'province' => $this->input->post('province'),
'country' => $this->input->post('country'),
'postal' => $this->input->post('postal'),
'phone' => $this->input->post('phone'),
'cell_phone' => $this->input->post('cell_phone'),
'other_phone' => $this->input->post('other_phone'),
'username' => $this->input->post('username'),
'password' => md5($this->input->post('password')),
'comments' => $this->input->post('comments'),
'date_registered' => date("d/m/Y")
);
$this->load->model('users_model');
$this->users_model->add_user($data);
}
function success() {
$data['main_content'] = 'signup_success';
$this->load->view('includes/template', $data);
}
}
I wanted to access the signup page from outside of being logged in I changed it so this:
Code:
<?php
class Signup extends Controller {
function index() {
$this->load->view('signup_view');
}
function is_logged_in() {
$is_logged_in = $this->session->userdata('is_logged_in');
if(!isset($is_logged_in) || $is_logged_in != true)
{
echo ('This session is not logged in. Access Denied');
echo ('<br />');
echo anchor('login', 'Login', 'title="Login"');
die();
}
}
function new_user() {
$data = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'email' => $this->input->post('email'),
'address' => $this->input->post('address'),
'city' => $this->input->post('city'),
'province' => $this->input->post('province'),
'country' => $this->input->post('country'),
'postal' => $this->input->post('postal'),
'phone' => $this->input->post('phone'),
'cell_phone' => $this->input->post('cell_phone'),
'other_phone' => $this->input->post('other_phone'),
'username' => $this->input->post('username'),
'password' => md5($this->input->post('password')),
'comments' => $this->input->post('comments'),
'date_registered' => date("d/m/Y")
);
$this->load->model('users_model');
$this->users_model->add_user($data);
}
function success() {
$data['main_content'] = 'signup_success';
$this->load->view('includes/template', $data);
}
}
It still give the "This session is not logged in. Access Denied" message from the is_logged_in function. I even got rid of the function from this controller and it still generates that message as if it calls the function.
Any help would be greatly appreciated. I know I'm missing something simple.