Jump to content

Message: Missing argument 1/Missing argument 2 for User::__construct()


Recommended Posts

Hey all,

 

Using codeigniter, I create a new user object and grab the user input (email and password) from a form:

 

public function signup(){	
	$this->template->render_content('template', '/users/signup');

	$user = new User($this->input->post('email'),$this->input->post('password'));
	if($_SERVER['REQUEST_METHOD'] == 'POST'){
		if($user.save()){
	    	redirect('/home/index', 'refresh'); 
		}
	    else{
	    	redirect('/users/login', 'refresh'); 
	    }
	}

}

 

The constructor function of user model assigns the user input to this object:

 

	public function __construct($email,$password){
		$this->email = $email;
		$this->password = $password;
	}

 

By using the __get and __set magic method, this calls two setter methods:

 

	public function setEmail($email){
		if ( ! is_null( $email ) ) {
			$this->_email = $email;
		}
		return null;
	}

	public function setPassword($password){
		if ( ! is_null( $password ) ) {
			User::$password_salt = User::randomize();
			User::$encrypted_password = User::encrypt($this->password,User::$password_salt);
		}
		return null;	
	}

 

I clearly pass two arguments when instantiating user. Yet I get this error message:

 

Message: Missing argument 1 for User::__construct()

 

Thanks for response.

 

Can someone move this to the general help forum? I meant to submit it there. Thanks.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.