I have a registration form where I check user input. Here is my controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Register extends CI_Controller {
public function index()
{
$this->load->model('Users_model');
$this->load->helper('form');
$this->load->library('form_validation');
$data['page_title'] = 'Register';
$this->load->view('header', $data);
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]|max_length[16]|xss_clean|callback_username_check');
$this->form_validation->set_rules('email', 'Email', 'trim|required|min_length[5]|max_length[64]|valid_email|callback_email_check');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_error_delimiters('<span class="error">', '</span>');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('register', $data);
}
else
{
$this->Users_model->add_user();
$this->load->view('register_success', $data);
}
$this->load->view('footer', $data);
}
}
The problem is this line: $this->Users_model->add_user();. I want to pass the username, email address and password of the user model to add the user to my database, but I'm not sure how I can get the POST data in this method. Usually I used $_POST['username']etc., but CodeIgniter ran some functions on input values ββ( trim(), xss_cleanetc.). How can I get these values ββand pass them to my method add_user()?
source
share