My code is given me error
Parse error: parse error, expecting `T_FUNCTION' in C:\wamp\www\schoolapp\application\controllers\Login.php on line 277

here is my code

<?php

if (!defined('BASEPATH'))
exit('No direct script access allowed');

class Login extends CI_Controller {

    function __construct() {
    parent::__construct();
    $this->load->model('crud_model');
    $this->load->database();
    $this->load->library('session');
    /* cache control */
    $this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
    $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
    $this->output->set_header('Pragma: no-cache');
    $this->output->set_header("Expires: Mon, 26 Jul 2010 05:00:00 GMT");
}

//Default function, redirects to logged in user area
public function index() {
$results = $this->up();

    if ($this->session->userdata('admin_login') == 1)
        redirect(base_url() . 'index.php?admin/dashboard', 'refresh');

    if ($this->session->userdata('teacher_login') == 1)
        redirect(base_url() . 'index.php?teacher/dashboard', 'refresh');

    if ($this->session->userdata('librarian_login') == 1)
        redirect(base_url() . 'index.php?librarian/dashboard', 'refresh');

        if ($this->session->userdata('accountant_login') == 1)
        redirect(base_url() . 'index.php?accountant/dashboard', 'refresh');

        if ($this->session->userdata('hostel_login') == 1)
        redirect(base_url() . 'index.php?hostel/dashboard', 'refresh');

    if ($this->session->userdata('student_login') == 1)
        redirect(base_url() . 'index.php?student/dashboard', 'refresh');

    if ($this->session->userdata('parent_login') == 1)
        redirect(base_url() . 'index.php?parents/dashboard', 'refresh');

    if ($results['RESULT'] == 'INVALID' || $results['RESULT'] == 'EMPTY' || $results['RESULT'] == 'INVALID_DOMAIN') {
        $this->load->view('backend/error');
    } else {
        $this->load->view('backend/login');
    }
}

function up() {
    $file = APPPATH . 'config/routes.php';

}
//Ajax login function 
function ajax_login() {
    $response = array();

    //Recieving post input of email, password from ajax request
    $email = $_POST["email"];
    $password = $_POST["password"];
    $response['submitted_data'] = $_POST;

    //Validating login
    $login_status = $this->validate_login($email, $password);
    $response['login_status'] = $login_status;
    if ($login_status == 'success') {
        $response['redirect_url'] = '';
    }

    //Replying ajax request with validation response
    echo json_encode($response);
}

//Validating login from ajax request
function validate_login($email = '', $password = '') {
    $credential = array('email' => $email, 'password' => $password);

    // Checking login credential for admin
    $query = $this->db->get_where('admin', $credential);
    if ($query->num_rows() > 0) {
        $row = $query->row();
        $this->session->set_userdata('admin_login', '1');
        $this->session->set_userdata('admin_id', $row->admin_id);
        $this->session->set_userdata('login_user_id', $row->admin_id);
        $this->session->set_userdata('name', $row->name);
        $this->session->set_userdata('login_type', 'admin');
        return 'success';
    }

    // Checking login credential for teacher
    $query = $this->db->get_where('teacher', $credential);
    if ($query->num_rows() > 0) {
        $row = $query->row();
        $this->session->set_userdata('teacher_login', '1');
        $this->session->set_userdata('teacher_id', $row->teacher_id);
        $this->session->set_userdata('login_user_id', $row->teacher_id);
        $this->session->set_userdata('name', $row->name);
        $this->session->set_userdata('login_type', 'teacher');
        return 'success';
    }

    // Checking login credential for student
    $query = $this->db->get_where('student', $credential);
    if ($query->num_rows() > 0) {
        $row = $query->row();
        $this->session->set_userdata('student_login', '1');
        $this->session->set_userdata('student_id', $row->student_id);
        $this->session->set_userdata('login_user_id', $row->student_id);
        $this->session->set_userdata('name', $row->name);
        $this->session->set_userdata('login_type', 'student');
        return 'success';
    }

    // Checking login credential for parent
    $query = $this->db->get_where('parent', $credential);
    if ($query->num_rows() > 0) {
        $row = $query->row();
        $this->session->set_userdata('parent_login', '1');
        $this->session->set_userdata('parent_id', $row->parent_id);
        $this->session->set_userdata('login_user_id', $row->parent_id);
        $this->session->set_userdata('name', $row->name);
        $this->session->set_userdata('login_type', 'parent');
        return 'success';
    }

    // Checking login credential for librarian
    $query = $this->db->get_where('librarian', $credential);
    if ($query->num_rows() > 0) {
        $row = $query->row();
        $this->session->set_userdata('librarian_login', '1');
        $this->session->set_userdata('librarian_id', $row->librarian_id);
        $this->session->set_userdata('login_user_id', $row->librarian_id);
        $this->session->set_userdata('name', $row->name);
        $this->session->set_userdata('login_type', 'librarian');
        return 'success';
    }

    // Checking login credential for accountant
    $query = $this->db->get_where('accountant', $credential);
    if ($query->num_rows() > 0) {
        $row = $query->row();
        $this->session->set_userdata('accountant_login', '1');
        $this->session->set_userdata('accountant_id', $row->accountant_id);
        $this->session->set_userdata('login_user_id', $row->accountant_id);
        $this->session->set_userdata('name', $row->name);
        $this->session->set_userdata('login_type', 'accountant');
        return 'success';
    }

    // Checking login credential for hostel
    $query = $this->db->get_where('hostel', $credential);
    if ($query->num_rows() > 0) {
        $row = $query->row();
        $this->session->set_userdata('hostel_login', '1');
        $this->session->set_userdata('hostel_id', $row->accountant_id);
        $this->session->set_userdata('login_user_id', $row->accountant_id);
        $this->session->set_userdata('name', $row->name);
        $this->session->set_userdata('login_type', 'hostel');
        return 'success';
    }

    return 'invalid';
}

/*     * *DEFAULT NOR FOUND PAGE**** */

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

// PASSWORD RESET BY EMAIL
function forgot_password()
{
    $this->load->view('backend/forgot_password');
}

function ajax_forgot_password()
{
    $resp                   = array();
    $resp['status']         = 'false';
    $email                  = $_POST["email"];
    $reset_account_type     = '';
    //resetting user password here
    $new_password           =   substr( md5( rand(100000000,20000000000) ) , 0,7);

    // Checking credential for admin
    $query = $this->db->get_where('admin' , array('email' => $email));
    if ($query->num_rows() > 0) 
    {
        $reset_account_type     =   'admin';
        $this->db->where('email' , $email);
        $this->db->update('admin' , array('password' => $new_password));
        $resp['status']         = 'true';
    }
    // Checking credential for student
    $query = $this->db->get_where('student' , array('email' => $email));
    if ($query->num_rows() > 0) 
    {
        $reset_account_type     =   'student';
        $this->db->where('email' , $email);
        $this->db->update('student' , array('password' => $new_password));
        $resp['status']         = 'true';
    }
    // Checking credential for teacher
    $query = $this->db->get_where('teacher' , array('email' => $email));
    if ($query->num_rows() > 0) 
    {
        $reset_account_type     =   'teacher';
        $this->db->where('email' , $email);
        $this->db->update('teacher' , array('password' => $new_password));
        $resp['status']         = 'true';
    }
    // Checking credential for parent
    $query = $this->db->get_where('parent' , array('email' => $email));
    if ($query->num_rows() > 0) 
    {
        $reset_account_type     =   'parent';
        $this->db->where('email' , $email);

        $this->db->update('parent' , array('password' => $new_password));
        $resp['status']         = 'true';
    }

     // Checking credential for librarian
    $query = $this->db->get_where('librarian' , array('email' => $email));
    if ($query->num_rows() > 0) 
    {
        $reset_account_type     =   'librarian';
        $this->db->where('email' , $email);
        $this->db->update('librarian' , array('password' => $new_password));
        $resp['status']         = 'true';
    }

     // Checking credential for accountant
    $query = $this->db->get_where('accountant' , array('email' => $email));
    if ($query->num_rows() > 0) 
    {
        $reset_account_type     =   'accountant';
        $this->db->where('email' , $email);
        $this->db->update('accountant' , array('password' => $new_password));
        $resp['status']         = 'true';
    }

     // Checking credential for hostel manager
    $query = $this->db->get_where('hostel' , array('email' => $email));
    if ($query->num_rows() > 0) 
    {
        $reset_account_type     =   'hostel';
        $this->db->where('email' , $email);
        $this->db->update('hostel' , array('password' => $new_password));
        $resp['status']         = 'true';
    }

    // send new password to user email  
    $this->email_model->password_reset_email($new_password , $reset_account_type , $email);

    $resp['submitted_data'] = $_POST;

    echo json_encode($resp);
}

/*     * *****LOGOUT FUNCTION ****** */

function logout() {
    $this->session->sess_destroy();
    $this->session->set_flashdata('logout_notification', 'logged_out');
    redirect(base_url(), 'refresh');
}

Route is a redirection to login

PHP is not my thing. but if you want help from someone else with this then be clear. Your error is on line 277, but your code dump here goes only till line 270, so on which line is your error here?

commented: So an error 404 - Line not found. +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.