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 8930719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:57:23+00:00 2026-06-15T08:57:23+00:00

Possible Duplicate: Call to a member function on a non-object I have just started

  • 0

Possible Duplicate:
Call to a member function on a non-object

I have just started learning cake php and am attempting to create a very simple registration form consisting of one field. I’m having trouble interacting with my model however. Code below:

This is my Register Controller:

class RegisterController extends AppController{

    public $helpers = array('Form', 'Html', 'Js');

    public function index(){

    }

}

This is my register controllers index.ctp view:

echo $this->Form->create('Users', array('controller' => 'Users', 'action' => 'createUser'));
echo $this->Form->input('username');
echo $this->Form->end('Register');

I then created a UsersController.php file and a Users.php (model) file to handle the validation and saving of the form data.

UsersController.php:

class UsersController extends AppController{


    public function createUser(){

        $this->Users->create();

        $this->Users->save($this->Request->data);

    }

}

And the Users.php model file:

class Users extends AppModel {

    public $validation = array(

        'username' => array(

            'rule1' => array(
                'rule' => 'isUnique',
                'message' => 'That username is already taken'
                ),
            'rule2' => array(

                'rule' => 'nonEmpty',
                'message' => 'This field cannot be empty',
                'required' => true

            )
        )
    );

}

Whenever I hit the ‘register’ button on my form however, I get the following error:

Call to a member function create() on a non-object

It’s referring to the following line in my UsersController.php file:

$this->Users->create();

I have a users table created in my cake database that the php files can see it. I don’t understand why my UsersController.php file can’t write to its model?

  • 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-15T08:57:25+00:00Added an answer on June 15, 2026 at 8:57 am

    You have to follow the coding standards with CakePHP. In this case the class “Users” will not work. You have to use class “User” and refactor the code to look for User.

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

Sidebar

Related Questions

Possible Duplicate: CakePHP: Call to a member function find() on a non-object I have
Possible Duplicate: PHP Fatal error: Call to a member function Execute() on a non-object
Possible Duplicate: Call to a member function bind_param() on a non-object I'm getting the
Possible Duplicate: Call to a member function on a non-object In my homepage view
Possible Duplicate: Call to a member function on a non-object What is wrong with
Possible Duplicate: Call to a member function on a non-object I try to call
Possible Duplicate: lambdas require capturing 'this' to call static member function? I want to
Possible Duplicate: PHP call class in class returns error:500 I have code that looks
Possible Duplicate: What will happen when I call a member function on a NULL
Possible Duplicate: How to get the address of an overloaded member function? I have

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.