CodeIgniter Forums
[SOLVED] How to get the USERNAME from registration in the tpl_general_message file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forum-10.html)
+--- Thread: [SOLVED] How to get the USERNAME from registration in the tpl_general_message file (/thread-63371.html)



[SOLVED] How to get the USERNAME from registration in the tpl_general_message file - IeMdev - 10-23-2015

Hi,
I have an application based on Codeigniter 3, however, the controllers are encrypted with ironcube.

For integration reasons with another app I need to get and store in a session var the 'username' that is submitted when a new account is registered and use this value in the tpl_general_message file that loads with the congratulations message.

In V2 of Codeigniter was was able to achieve this by simply adding to the Form Helper file:
Code:
if(isset($_POST['username'])){
$_SESSION['jamUsername'] = $_POST['username'];
}

However, it does not seem to be working with V3 so now things are broken. There is no value for $_POST['username'] at this point of the process.

Any better ways of getting this value?

Thanks


RE: How to get the USERNAME from registration in the tpl_general_message file - rtorralba - 10-23-2015

(10-23-2015, 04:11 AM)IeMdev Wrote: Hi,
I have an application based on Codeigniter 3, however, the controllers are encrypted with ironcube.

For integration reasons with another app I need to get and store in a session var the 'username' that is submitted when a new account is registered and use this value in the tpl_general_message file that loads with the congratulations message.

In V2 of Codeigniter was was able to achieve this by simply adding to the Form Helper file:

Code:
if(isset($_POST['username'])){
    $_SESSION['jamUsername'] = $_POST['username'];
}

However, it does not seem to be working with V3 so now things are broken. There is no value for $_POST['username'] at this point of the process.

Any better ways of getting this value?

Thanks

You modified system form_helper file?

I think the correct way to do this is the following:

At controller that you use to auntenticate for example Auth at login action you can make the following (assuming you have to check the username and password and have a model for it):


PHP Code:
if ($this->input->post('username') && $this->input->post('password')) {
  if($this->auth_model->checkUser($this->input->post('username'), $this->input->post('password'))) {
    $this->session->set_userdata('jamUsename'$this->input->post('username'));
  }




RE: How to get the USERNAME from registration in the tpl_general_message file - IeMdev - 10-23-2015

Thanks for the very quick response rtorralba.

However, I can not do this because all of the controllers are encrypted using iconcube. Using the helper file was a hack as if is not encrypted.

I've just come up with another idea and that is to add the session var setting to the config file as the controllers would all load this file. Not sure if that will work and no doubt there are much better ideas on how to achieve this.


RE: How to get the USERNAME from registration in the tpl_general_message file - IeMdev - 10-24-2015

I've solved the issue by adding the set session var as follows

Code:
if(isset($_POST['username'])){
   $_SESSION['jamUsername'] = $_POST['username'];
}

nto the cofig file.