Jump to content

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


johnmerlino

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.