Unable to load the requested file

Hi everyone, I have a problem regarding my website. After I uploaded my files into server, I try to login my website account, but after I login, it showed “Unable to load the requested file: template\student_homepage.php”. Other type of user account also have the same problem. Although I already change the database hostname, username and password. But it still having the same problem. Can I know what is the problem here since when I do in localhost do not have any problem? Thanks.

Are you sure the file directory is correct? We cannot help, if we have no URL, or code to inspect at. Also this topic is off category. @Oxy, @Greenreader9 thanks!

Sorry I forgot to screenshot the url together. So, here is the pciture with url:


here is the login page for view:

	<div class="container">
		<!-- <img src="<?php //echo base_url(); ?>images/dodrio.png" alt=""> -->
		<div class="container h-100">
			<div class="row h-100 justify-content-center align-items-center">
				<div class="card login-form">
					<div class="card-body">
						<h3 class="card-title text-center">Log in to Your Account</h3>
						<div class="card-text">
							<div class="alert alert-info" id="errorAlert" role="alert" hidden>
							</div>
							<!-- <div class="alert alert-danger fade show" role="alert">Incorrect username or password.</div> -->
							<form class="form-signin form" action="<?php echo site_url('login/auth');?>" method="post">
								<!-- to error: add class "has-danger" -->
								<div class="form-group">
									<label for="email">Email address</label>
									<input type="email" name="email" id="email" class="form-control form-control-sm" required>
								</div>
								<div class="form-group">
									<label for="password">Password</label>
									<!-- <a href="#" style="float:right;font-size:12px;">Forgot password?</a> -->
									<input type="password" name="password" id="password" class="form-control form-control-sm" required>
								</div>
								<div class="form-group">
										<label for="user_type">Login as:</label>
										<select class="form-control" name="user_type" required="">
											<option>student</option>
											<option>lecturer</option>
											<option>staff</option>
											<option>parent</option>
											<option>admin</option>
										</select>
										<div class="invalid-feedback"></div>
									</div>
								<button type="submit" id="loginBtn" class="btn btn-primary btn-block">Sign in</button>

									<a href="<?php echo site_url('register/registerparentinlogin');?>"><button type="button" class="btn btn-primary btn-block">Register Parents </button></a>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<script>
		$(document).ready(function() {
			//TODO Remove flashdata for user id. This is for testing a part of query in login_model where 1 query is performed right after the first one. Do query 1, take user_id from query 1 to be inserted into query 2.
			var userId = "<?php echo $this->session->flashdata('user-id');?>";
			var loginError = "<?php echo $this->session->flashdata('login-error');?>";

			console.log("Last inserted user_id: " + userId);

			if(loginError){
				$('#errorAlert').attr("hidden",false);
				$('#errorAlert').html(loginError);
			}

		}
);
	</script>

Here is the code for controller:

<?php
class Login extends CI_Controller{
	function __construct(){
		parent::__construct();
		$this->load->helper('hash');
		$this->load->model('Profile Data/User_login_model','login');
		$this->load->model('Profile Data/User_register_model','register');
	}

	function index(){
		$data['meta_title'] = 'Login';
		$data['content_heading'] = 'Log in to Your Account';
		$data['meta_keywords'] = 'home_meta_keywords';
		$data['main_content'] = 'Manage User/user_login_view';
		$this->load->view('template/login_template', $data);
	}

	function auth(){
		$email    = $this->input->post('email',TRUE);
		$password = $this->input->post('password',TRUE);
		$user_type = $this->input->post('user_type');
		$result = $this->login->login($email, $password, $user_type);
		$studentTerminate = "";
		$lecturerTerminate = "";
		$staffTerminate = "";
		$parentTerminate = "";
		if($user_type == "student"){
			$studentTerminate = $this->login->validatestudentID($email);
		}elseif($user_type == "lecturer"){
			$lecturerTerminate = $this->login->validatelecturerID($email);
		}elseif($user_type == "staff"){
			$staffTerminate = $this->login->validatestaffID($email);
		}elseif($user_type == "parent"){
			$parentTerminate = $this->login->validateparentIC($email);
		}

		if(!$this->register->isExistingEmail($email, $user_type)){
			echo $this->session->set_flashdata('login-error','Email does not exist, create a new account');
			redirect('login');
		}
		if($studentTerminate == "terminated"){
		 	echo $this->session->set_flashdata('login-error','Your Account Has Been Terminated!');
	     	redirect('login');
		}elseif($lecturerTerminate == "terminated"){
		 	echo $this->session->set_flashdata('login-error','Your Account Has Been Terminated!');
	     	redirect('login');
		}elseif($staffTerminate == "terminated"){
		 	echo $this->session->set_flashdata('login-error','Your Account Has Been Terminated!');
	     	redirect('login');
		}elseif($parentTerminate == "terminated"){
		 	echo $this->session->set_flashdata('login-error','Your Account Has Been Terminated!');
	     	redirect('login');
		}
		
		if(count($result) > 0)
		{
			foreach ($result as $res)
			{
				$sessionArray = array('id'=> next($res),//reset() takes the first element of an object. In this case,1, staff_id or rider_id
					'first_name'=>$res->first_name,
					'last_name'=>$res->last_name,
					'email'=>$res->email,
					'user_type'=>$user_type,
					//'level'=>$res->user_level,
					'logged_in' => TRUE
				);
				$this->session->set_userdata($sessionArray);

				if ($this->session->userdata['logged_in'] == TRUE)
        		{
        			// access login for student
					if($user_type === 'student'){
						redirect('page');

					// access login for lecturer
					}elseif($user_type === 'lecturer'){
						redirect('page');

					// access login for staff
					}elseif($user_type === 'staff'){
						redirect('page');

			    	// access login for parent
					}elseif($user_type === 'parent'){
						redirect('page');
					}

					// access login for admin
					elseif($user_type === 'admin'){
						redirect('page');
					}
        		}
        		else
        		{
            		redirect('login'); //if session is not there, redirect to login page
        		}
			}
		}else{
			echo $this->session->set_flashdata('login-error','Incorrect email or password.');
			redirect('login');
		}
	}

	function logout(){
		$this->session->sess_destroy();
		redirect('login');
	}

}

Here is the code for model:

<?php
class User_login_model extends CI_Model{

	var $tablestd = 'student';
	var $tablelec = 'lecturer';
	var $tablestf = 'staff';
	var $tableprt = 'parent';
	var $tableadm = 'admin';
	var $tablestdtl = 'student_terminate_list';
	var $tablelectl = 'lecturer_terminate_list';
	var $tablestftl = 'staff_terminate_list';
	var $tableprttl = 'parent_terminate_list';

	public function __construct()
	{
		parent::__construct();
		$this->load->database();
	}

	function validatestudentID($email){

		//get id by email
		$this->db->from($this->tablestd);
		$this->db->where('email',$email);
		$query = $this->db->get();
		$user = $query->result();
		$student_id = $user[0]->student_id;

		$this->db->from($this->tablestdtl); //SELECT FROM
		$this->db->where('student_id',$student_id); //WHERE
		$terminate_query = $this->db->get();
		$terminate = $terminate_query->result();

		$this->db->from($this->tablestd);
		$this->db->where('student_id',$student_id);
		$std_query = $this->db->get();
		$std = $std_query->result();


		if(!empty($std)){
			if(!empty($terminate)){
				// echo "terminated";
				return "terminated";
			} else {
				// echo "not terminated";
				return "not terminated";
			}
		} else {
			return FALSE;
			// echo "student does not exist";
			return "not exist";
		}
	}

	function validatelecturerID($email){

		//get id by email
		$this->db->from($this->tablelec);
		$this->db->where('email',$email);
		$query = $this->db->get();
		$user = $query->result();
		$lecturer_id = $user[0]->lecturer_id;

		$this->db->from($this->tablelectl); //SELECT FROM
		$this->db->where('lecturer_id',$lecturer_id); //WHERE
		$terminate_query = $this->db->get();
		$terminate = $terminate_query->result();

		$this->db->from($this->tablelec);
		$this->db->where('lecturer_id',$lecturer_id);
		$lec_query = $this->db->get();
		$lec = $lec_query->result();


		if(!empty($lec)){
			if(!empty($terminate)){
				// echo "terminated";
				return "terminated";
			} else {
				// echo "not terminated";
				return "not terminated";
			}
		} else {
			return FALSE;
			// echo "lecturer does not exist";
			return "not exist";
		}
	}

	function validatestaffID($email){

		//get id by email
		$this->db->from($this->tablestf);
		$this->db->where('email',$email);
		$query = $this->db->get();
		$user = $query->result();
		$staff_id = $user[0]->staff_id;

		$this->db->from($this->tablestftl); //SELECT FROM
		$this->db->where('staff_id',$staff_id); //WHERE
		$terminate_query = $this->db->get();
		$terminate = $terminate_query->result();

		$this->db->from($this->tablestf);
		$this->db->where('staff_id',$staff_id);
		$stf_query = $this->db->get();
		$stf = $stf_query->result();


		if(!empty($stf)){
			if(!empty($terminate)){
				// echo "terminated";
				return "terminated";
			} else {
				// echo "not terminated";
				return "not terminated";
			}
		} else {
			return FALSE;
			// echo "staff does not exist";
			return "not exist";
		}
	}

	function validateparentIC($email){

		//get id by email
		$this->db->from($this->tableprt);
		$this->db->where('email',$email);
		$query = $this->db->get();
		$user = $query->result();
		$parent_ic = $user[0]->parent_ic;

		$this->db->from($this->tableprttl); //SELECT FROM
		$this->db->where('parent_ic',$parent_ic); //WHERE
		$terminate_query = $this->db->get();
		$terminate = $terminate_query->result();

		$this->db->from($this->tableprt);
		$this->db->where('parent_ic',$parent_ic);
		$prt_query = $this->db->get();
		$prt = $prt_query->result();


		if(!empty($prt)){
			if(!empty($terminate)){
				// echo "terminated";
				return "terminated";
			} else {
				// echo "not terminated";
				return "not terminated";
			}
		} else {
			return FALSE;
			// echo "parent does not exist";
			return "not exist";
		}
	}

	function login($email, $password, $userType)
	{
		if ($userType == "student") {
			$this->db->from($this->tablestd);
		}else if ($userType == "lecturer") {
			$this->db->from($this->tablelec);
		}else if ($userType == "staff") {
			$this->db->from($this->tablestf);
		}else if ($userType == "parent") {
			$this->db->from($this->tableprt);
		}else if ($userType == "admin") {
			$this->db->from($this->tableadm);
		}

		$this->db->where('email',$email);
		$query = $this->db->get();

		$user = $query->result();

		if(!empty($user)){
			if(verifyHashedPassword($password, $user[0]->password)){
				// echo print_r("OK");
				return $user;
			} else {
				// echo print_r("Wrong pass");
				return array();
			}
		} else {
			// echo print_r("Email does not exist");
			return array();
		}
	}

}

Here is the coding for page:

<?php
header('Access-Control-Allow-Origin: *');
class Page extends CI_Controller{
	function __construct(){
		parent::__construct();
		// $this->load->model('User Data/profile_model','profile');
		if($this->session->userdata('logged_in') !== TRUE){
			redirect('login');
		}
	}

	public function index()
	{
		$data['meta_title'] = 'Homepage';
		$data['content_heading'] = 'Welcome to Online Web Attendance Management System!';
		$data['meta_keywords'] = 'home_meta_keywords';
		$data['main_content'] = 'template\homepage';
		$data['user_id'] = $this->session->userdata('id');

		if($this->session->userdata('user_type')==='staff'){
			$data['user_type'] = 'staff';
			$data['meta_user_level_title'] = 'Staff';
			$data['main_content'] = 'template\staff_homepage';
			$this->load->view('template/template', $data);
		}elseif($this->session->userdata('user_type')==='student'){
			$data['user_type'] = 'student';
			$data['meta_user_level_title'] = 'Student';
			$data['main_content'] = 'template\student_homepage';
			$this->load->view('template/template', $data);
		}elseif($this->session->userdata('user_type')==='lecturer'){
			$data['user_type'] = 'lecturer';
			$data['meta_user_level_title'] = 'Lecturer';
			$data['main_content'] = 'template\lecturer_homepage';
			$this->load->view('template/template', $data);
		}elseif($this->session->userdata('user_type')==='parent'){
			$data['user_type'] = 'parent';
			$data['meta_user_level_title'] = 'Parent';
			$data['main_content'] = 'template\cust_homepage';
			$this->load->view('template/template', $data);
		}elseif($this->session->userdata('user_type')==='admin'){
			$data['user_type'] = 'admin';
			$data['meta_user_level_title'] = 'Admin';
			$data['main_content'] = 'template\admin_homepage';
			$this->load->view('template/template', $data);
		}else{
			echo "Access Denied";
			redirect('login');
		}
	}

}

The directories suppose dont have any problem.

Ooh, your site uses PHP. My bad, i’m just learning PHP basics. Maybe someone who know will help you out! Thanks!

It’s ok, Thanks btw.

1 Like

Shouldn’t this be template/homepage? On Windows, directories are separated with a backslash, but on Linux (which runs on almost all servers, including ours) and MacOS it uses a forward slash.

Same for the other occurrences.

5 Likes

Ok. it works now, i didn’t realize the backslash, thanks for your help :grinning_face_with_smiling_eyes:.

2 Likes