[eluser]bevans[/eluser]
I get an error message that says:
"A PHP Error was encountered
Severity: Notice
Message: Undefined property: Register::$register_model
Filename: controllers/register.php
Line Number: 52
Fatal error: Call to a member function register_insert() on a non-object in D:\EasyEclipse Projects\iFitIgniter\system\application\controllers\register.php on line 52"
What does it mean to have a "Call to a member function register_insert() on a non-object"?
I am doing a registration page.
I have 3 things: a model, a view, and a controller.
The controller loads the view and the model.
The connection to the db works great. The view pages loads correctly and shows what it should. I then fill in the fields (name, email, etc.) BUT when I click submit I get the error.
Will some one please explain what the error means and how to fix it???
Thanks in advance.
Here is the CONTROLLER code.
Code:
class Register extends Controller {
public $fields = array('firstname','lastname', 'email', 'screenname', 'password');
function index()
{
parent::Controller();
$this->load->model('register_model');
$this->load->library('validation');
$rules['firstname'] = "trim|required|min_length[5]|max_length[12]";
$rules['lastname'] = "trim|required";
$rules['eamil'] = "trim|required";
$rules['screenname'] = "trim|required";
$rules['password'] = "trim|required|valid_email";
$this->validation->set_rules($rules);
$fields['firstname'] = 'firstname';
$fields['lastname'] = 'lastname';
$fields['email'] = 'email';
$fields['screenname'] = 'screenname';
$fields['password'] = 'password';
$this->validation->set_fields($fields);
/*
*
if($this->validation->run() == False)
{
$this->load->view('register_view');
}else{
$this->load->view('');
}
*/
$this->load->view('register_view');
}
function register_insert()
{
$this->load->database();
//$num_rows =
$this->register_model->register_insert();
//$data['num_rows'] = $num_rows;
$this->load->view('register_view.php');
}
}
Here is the VIEW code
Code:
<html>
<head>
<title></title>
</head>
<body>
<?=$this->validation->error_string; ?>
<?=form_open('/register/register_insert');?>
First Name:
<input type="text" name="firstname" value="<?=$this->validation->firstname;?>" size="20" /><?=$this->validation->firstname_error; ?><br />
Last Name:
<input type="text" name="lastname" value="<?=$this->validation->lastname;?>" size="20" /><?=$this->validation->lastname_error; ?><br />
Email:
<input type="text" name="email" value="<?=$this->validation->email;?>" size="20" /><?=$this->validation->email_error; ?><br />
Choose a Screen Name:
<input type="text" name="screenname" value="<?=$this->validation->screenname;?>" size="20" /><?=$this->validation->screenname_error; ?><br />
Password:
<input type="password" name="password" value="<?=$this->validation->password;?>" size="20" /><?=$this->validation->password_error; ?><br />
<input type="submit" name="submit" value="Register Now">
</form>
</body>
</html>
Here is the MODEL code
Code:
class Register_model extends Model {
public $firstname = '';
public $lastname = '';
public $email = '';
public $screenname = '';
public $password = '';
public $signupdate = '';
function register_model()
{
parent::Model();
$this->load->helper('form');
}
function register_insert()
{
$this->firstname = $_POST['firstname'];
$this->lastname = $_POST['lastname'];
$this->email = $_POST['email'];
$this->screenname = $_POST['screenname'];
$this->password = $_POST['password'];
$sql_query = "INSERT INTO DB ("
. " EMAIL,"
. " FIRSTNAME,"
. " LASTNAME,"
. " SCREENNAME,"
. " PASSWORD"
. " ) VALUES ("
. " ?,"
. " ?,"
. " ?,"
. " ?,"
. " ?"
. " )";
}
}