[eluser]miwrath[/eluser]
can any one can correct this code please...
this is my registration model that should be inserting data into the db...
but unfortunately this error comes out:
Code:
( ! ) Fatal error: Call to undefined method User_reg::check_username_exists() in D:\wamp\www\registrar\system\application\controllers\registrar.php on line 62
Call Stack
# Time Memory Function Location
1 0.0011 381952 {main}( ) ..\index.php:0
2 0.0030 431568 require_once( 'D:\wamp\www\registrar\system\codeigniter\CodeIgniter.php' ) ..\index.php:115
3 0.1436 3040856 call_user_func_array ( ) ..\CodeIgniter.php:236
4 0.1436 3040904 Registrar->register( ) ..\CodeIgniter.php:0
5 0.1439 3048992 CI_Form_validation->run( ) ..\registrar.php:31
6 0.1456 3054376 CI_Form_validation->_execute( ) ..\Form_validation.php:337
7 0.1471 3055224 Registrar->username_not_exists( ) ..\Form_validation.php:589
here is my controller code:
Code:
function register()
{
$this->form_validation->set_rules('username', 'Username', 'trim|required|alpha_numeric|xss_clean|strtolower|callback_username_not_exists');
$this->form_validation->set_rules('password', 'Password', 'trim|required|alpha_numeric|xss_clean');
$this->form_validation->set_rules('password_conf', 'Password Confirmation', 'trim|required|alpha_numeric|xss_clean|matches[password]');
$this->form_validation->set_rules('teach_id', 'ID Number', 'trim|required|alpha_numeric|min_length[10]|xss_clean');
$this->form_validation->set_rules('f_name', 'First Name', 'trim|required|alpha_numeric|xss_clean');
$this->form_validation->set_rules('m_name', 'Middle Name', 'trim|required|alpha_numeric|xss_clean');
$this->form_validation->set_rules('l_name', 'Last Name', 'trim|required|alpha_numeric|xss_clean');
$this->form_validation->set_rules('position', 'Position', 'trim|required|alpha_numeric|xss_clean');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('register');
}
else
{
//everything is good!
$username = $this->input->post('username');
$password = $this->input->post('password');
$password_conf = $this->input->post('password_conf');
$teach_id = $this->input->post('teach_id');
$f_name = $this->input->post('f_name');
$m_name = $this->input->post('m_name');
$l_name = $this->input->post('l_name');
$position = $this->input->post('position');
$this->User_reg->register_user($username, $password, $password_conf, $f_name, $m_name, $l_name, $teach_id, $position);
}
}
and this is my model for the registration:
Code:
<?php
class User_reg extends Model
{
function User_reg()
{
parent::Model();
}
function register_user($username, $password, $password_conf, $f_name, $m_name, $l_name, $teach_id, $position)
{
$sha1_password = sha1 ($password);
$query_str = "INSERT INTO accnt_info (username,password,teach_id,f_name,m_name,l_name,position)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$this->db->query($query_str, array($username, $sha1_password, $password_conf, $teach_id, $f_name, $m_name, $l_name, $position));
}
}