Welcome Guest, Not a member yet? Register   Sign In
Blank page when logging in
#1

[eluser]cerberus478[/eluser]
Hi I'm busy doing a tutorial on HMVC and I've done everything that the tutorial said but when I log in, I go to the "login/validate_credentials" and have a blank page instead of the "site/members_area".

I'm using codeiginter 2.1.4

login controller
Code:
class Login extends MX_Controller {

  function __construct() {
  parent::__construct();

}


function index()
{
  $data['main_content'] = 'login_form';
  $this->load->view('includes/template', $data);  
}

function validate_credentials()
{  
  $this->load->model('membership_model');
  $query = $this->membership_model->validate();
  
  if($query) // if the user's credentials validated...
  {
   $data = array(
    'username' => $this->input->post('username'),
    'is_logged_in' => true
   );
   $this->session->set_userdata($data);
   redirect('site/members_area');
  }
  else // incorrect username or password
  {
   $this->index();
  }
}

function signup()
{
  $data['main_content'] = 'signup_form';
  $this->load->view('includes/template', $data);
}

function create_member()
{
  $this->load->library('form_validation');
  
  // field name, error message, validation rules
  $this->form_validation->set_rules('first_name', 'Name', 'trim|required');
  $this->form_validation->set_rules('last_name', 'Last Name', 'trim|required');
  $this->form_validation->set_rules('email_address', 'Email Address', 'trim|required|valid_email');
  $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[4]');
  $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]|max_length[32]');
  $this->form_validation->set_rules('password2', 'Password Confirmation', 'trim|required|matches[password]');
  
  
  if($this->form_validation->run() == FALSE)
  {
   $this->load->view('signup_form');
  }
  
  else
  {  
   $this->load->model('membership_model');
  
   if($query = $this->membership_model->create_member())
   {
    $data['main_content'] = 'signup_successful';
    $this->load->view('includes/template', $data);
   }
   else
   {
    $this->load->view('signup_form');  
   }
  }
  
}

function logout()
{
  $this->session->sess_destroy();
  $this->index();
}

function is_logged_in()
{
  $is_logged_in = $this->session->userdata('is_logged_in');
  if(!isset($is_logged_in) || $is_logged_in != true)
  {
   echo 'You don\'t have permission to access this page. <a href="../login">Login</a>';
   die();  
   //$this->load->view('login_form');
  }  
}
}


This is the site controller
Code:
&lt;?php

class Site extends  MX_Controller
{
function __construct()
{
  parent::__construct();
  Modules::run('login/is_logged_in');

}

function members_area()
{
  $this->load->view('logged_in_area');
}

function another_page() // just for sample
{
  echo 'good. you\'re logged in.';
}



}
#2

[eluser]cerberus478[/eluser]
I have figured out what was wrong. It wouldn't work because I was missing a } at the end of one of my functions in my membership_model
#3

[eluser]CroNiX[/eluser]
Do you have display_errors turned on? That error should be shown to you on a development machine.
#4

[eluser]cerberus478[/eluser]
I don't have display_errors turned on. Where in codeigniter is that?
#5

[eluser]Tpojka[/eluser]
Code:
-application
-system
-.htaccess
-index.php // <- this file

#6

[eluser]cerberus478[/eluser]
greate thanks
#7

[eluser]CroNiX[/eluser]
It's not a CI setting, it's a PHP setting. I set it in my ENVIRONMENT section (index.php) so that development environment displays errors and testing and production do not.




Theme © iAndrew 2016 - Forum software by © MyBB