Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8369585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:41:11+00:00 2026-06-09T13:41:11+00:00

I am writting my first CodeIgniter script and I can’t get the following model

  • 0

I am writting my first CodeIgniter script and I can’t get the following model to load, if anyone could maybe help me?

Here is my controller file:

public function process(){
// Load the model
$this->load->model('users/login', 'users');

// Validate the user can login
$result = $this->users->validate();

// Now we verify the result
if(!$result){
    // If user did not validate, then show them login page again
    $this->index();
}else{
    // If user did validate,
    // Send them to members area
    redirect('home');
}      
}

And here is my model

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


class Login_Model extends CI_Model{
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }

    public function validate(){

        // grab user input
        $username = $this->security->xss_clean($this->input->post('username'));
        $password = $this->security->xss_clean($this->input->post('password'));

        // Prep the query
        $this->db->where('username', $username);
        $this->db->where('password', $password);

        // Run the query
        $query = $this->db->get('users');
        // Let's check if there are any results
        if($query->num_rows == 1)
        {
            // If there is a user, then create session data
            $row = $query->row();
            $data = array(
                    'userid' => $row->userid,
                    'fname' => $row->fname,
                    'lname' => $row->lname,
                    'username' => $row->username,
                    'validated' => true
                    );
            $this->session->set_userdata($data);
            return true;
        }
        // If the previous process did not validate
        // then return false.
        return false;
    }
}
?>

I can confirm the the process function is loading however any code that goes underneath the $results = $result = $this->users->validate(); doesn’t appear. The model is also loading, it is as soon as I try call a function, the script kills itself.

Sorry if this question is a little bland.

Thanks
Peter

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:41:13+00:00Added an answer on June 9, 2026 at 1:41 pm

    It all came down to my code. Your models class name must be equal to the name of the model file.

    So in this case, I should have named my file login_model.php and then the class itself must be called Login_model (the first character must be uppercase, all other characters must be lowercase). When calling the model in the controller it must all be lower case like:

    $this->load->model('login_model');
    

    Hope this is help to anyone in the future, thanks to all for the efforts and comments 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe somebody could help me. I need a two methods. The first should open
I'm writting my first jQuery script which should render a list of anchors in
Writing my first nested SELECT statement and I'm hoping someone can help me out.
I am writing my first FireFox extension and I have some questions. Maybe someone
If you like problems to resolve, here a big one :D First, It isn't
I'm writing my first Codeigniter web app, and I'd like to use AJAX to
I am about to start writing my first big CodeIgniter application, but before I
I`m writing my first codeigniter (news) website. I wonder what is the most appropriate
I have been writting a keyword search script based on this tutorial: http://www.hackosis.com/2007/11/06/howto-simple-search-engine-with-php-and-mysql/ Like
All, I am writting a php script that runs as part of a joomla

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.