I am trying to design a user registration form using code igniter 2.1.0. I have used the following code in the regitration.php in controllers to add users.
class Registration extends CI_Controller
{
function __construct() {
parent::__construct();
}
function index()
{
$data['main_content'] = 'registration';
// Checks to see if form validation rules were met an executed properly. If not, will return with registration form.
if ($this->form_validation->run('registration') === FALSE)
{
$data ['title'] = 'Registration';
$this->load->view('include/template', $data);
}
// If validation passes, information will be passed along to the MODEL to be processed and the account will be created.
else
{
$this->load->model('registration_model');
$this->registration_model->addUser();
$this->session->set_flashdata('success', 'Your account has been successfully created');
redirect(uri_string());
}
}
}
But it showed me an error of Call to a member function run() on a non-object. How do i correct that?
Please include
and try now
It seems like $session class is not initializing correctly.
For this
"In order to use the Session class you are required to set an encryption key in your config file.".add this to your config.php