Welcome Guest, Not a member yet? Register   Sign In
An Error Was Encountered Unable to load the requested file: home.php
#1

[eluser]theknight[/eluser]
Hi All,

For the most part my web app works fine. However sometimes when I log in, I occasionally get the following error:

An Error Was Encountered Unable to load the requested file: home.php

Why is this happening?

Cheers.
#2

[eluser]theknight[/eluser]
Code:
function login(){
  if($this->members->logged_in()){
    
   $this->data['user']=$this->members->getDetails($this->session->userdata('user'));  
   $this->load->view('home',$this->data);  
  }else{
   $this->data['pageTitle']='Welcome';
  
   if(isset($_POST['username'])){ // logging in
    $login_res=$this->members->login();
    if(!$login_res['success']){
     $this->data['logged_in']=false;
     $this->data['errors']=genErrorsOutput($login_res['errors']); // generete errors list
     $this->data=array_merge($this->data,$_POST); // show the filled form data    
     $this->load->view('login',$this->data);  
    }else{ // success
     $this->data['logged_in']=true;
                    //print_r($login_res['permInt']);
                    //exit;
     header('Location: '.$this->data['base_url'].'index.php');
    }
   }else{
    $this->load->view('login',$this->data);
   }
  }
//  $this->load->view('login',$this->data);  
}

Here is my controller code.
#3

[eluser]theknight[/eluser]
Just noticed that this happens if a user tries to log in at the same time. Not entirely sure what is going on here.
#4

[eluser]InsiteFX[/eluser]
Try:
Code:
redirect('/', 'refresh');
// instead of
header('Location: '.$this->data['base_url'].'index.php');
#5

[eluser]theknight[/eluser]
Hi thanks,

I think the problem is with this segment of code:

Code:
$this->data['user']=$this->members->getDetails($this->session->userdata('user'));  
   $this->load->view('home',$this->data);

After the user logs in, it crashes if they try to log in twice with the same browser session. Although I am not exactly sure what the issue is.
#6

[eluser]InsiteFX[/eluser]
See if this will work:
Code:
redirect(site_url(), 'refresh');

If it is crashing when the user trys to login twice, you should being
checking to see if user_id is already logged in.

Use CodeIgniters Form_validation class and set the rules on the user name to a callback
to see if the user name matches.

Check your session user_id and see if it matches your database record before trying to
log them in again.

Here is where your problem is:
Code:
if(isset($_POST['username'])){ // logging in
// if they are already logged in you do not want to do this!
    $login_res=$this->members->login();
#7

[eluser]theknight[/eluser]
[quote author="InsiteFX" date="1336685049"]See if this will work:
Code:
redirect(site_url(), 'refresh');

If it is crashing when the user trys to login twice, you should being
checking to see if user_id is already logged in.

Use CodeIgniters Form_validation class and set the rules on the user name to a callback
to see if the user name matches.

Check your session user_id and see if it matches your database record before trying to
log them in again.
[/quote]

Hi I am not storing session Ids within the database, rather I am creating them on the fly. As soon as the user logs in first time.

Code:
Here is where your problem is:
[code]
if(isset($_POST['username'])){ // logging in
// if they are already logged in you do not want to do this!
    $login_res=$this->members->login();
[/quote]

Is there anyway thru php I can check if the session has already been created, I uses $_SESSION variable to check but it was empty.

Doing this too:

echo $this->session->userdata('user');

Cheers.
#8

[eluser]InsiteFX[/eluser]
Show your code were you are setting the users details and session!
#9

[eluser]theknight[/eluser]
Hey man, sure, in function login - before that is just general validation check, to see if the user exists etc etc:

Code:
$this->session->set_userdata(array('user'=>$res['Id']));
          
     $this->db->select(castedColumns($this->contacts_table, $this->db));
     $q = $this->db->get_where($this->contacts_table, array('Id' => $res['Id']));
     $res_contacts = $q->row_array();
    
     $this->session->set_userdata(array('Parent_Id' => $ContactId,
                    'StaffMember_Id' => $staffId,
                    'Portal' => "1"));
                
            } else {

[....]

if(count($errors)==0)
   return array('success'=>true,'errors'=>false);
  else
   return array('success'=>false,'errors'=>$errors);

Which corresponds to this segment of code within the controller.

Code:
// if they are already logged in you do not want to do this!
    $login_res=$this->members->login();
#10

[eluser]theknight[/eluser]
Shouldn't it overwrite the session?




Theme © iAndrew 2016 - Forum software by © MyBB