After a few testing here and there, I have finally found a way where I can get the registered username. But I still can't make it to display on the page. I am stuck at getting the value from Model to Controller.
Below are my codes:
Model (user_model):
public function create_user( $role, $insert_array = array() )
{
if( ! empty( $insert_array ) OR $this->validate() === TRUE )
{
...
// Verify transaction was successful
if( $this->db->trans_status() !== FALSE )
{
// Load var to confirm user inserted into database
$this->load->vars( array( 'user_created' => 1 ) );
$reg_username = $user_data['user_name'];
}
return TRUE;
}
return FALSE;
}
View:
if( isset( $validation_passed ) && $reg_mode == 1 )
{
echo '
<div class="feedback confirmation">
<p>
Thank you for registering. Your new username is : You may now ' . secure_anchor('user', 'login') . '.
</p>
</div>
';
}
Controller:
$this->load->model('user_model');
$this->user_model->create_user( 'customer', array() );
What and how should I do it?
Appreciate if you guys can help me out on this. Thanks in advance.
You are not passing any arguments to your function when calling in view
Instead of this
echo $this->formval_callbacks->_username_check(); // no arguments passed
Try
echo $this->formval_callbacks->_username_check('Bob'); // Bob is just an example username given
When you call a view from your controller, then use can pass an associative array as a 2nd parameter to the view. The values in the array then become variables in the view.
In the controller
$this->load->model('required_model');
$user_data = $this->required_model->get_user_info();
//This should return an associative array from your model
//$user_data['username'] = username;
//$user_data['other_data'] = other_data;
$this->load->view('required_view',$user_data);
Inside your view, use the variable $username and $otherdata to display the information.