CodeIgniter Forums
Controller who detect the use of URI segments - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Controller who detect the use of URI segments (/showthread.php?tid=11623)



Controller who detect the use of URI segments - El Forum - 09-16-2008

[eluser]Sein Kraft[/eluser]
Hi everybody!

I'm working in a user management system and I've a trouble x3

I have a function called "Activate" with a variable catch.

Code:
function Activate($key)
{
}

And the system has the possibility of detect the content of $key. If the variable have data jump to the model to activate the user. And If not show a view with a simple form who request the activation key an then call the model and activate.

Code:
function Activate($key)
{
   if ($key = '')
      {
         //form validation...
         $this->load->view('user_activate', $data);
      }
   else
      {
         //send $key to model...
         $this->load->model('model_user','', TRUE);
         $this->model_user->activate_user($key);
      }
}

But the system doesn't work properly. It show an error in the first line of the function because it expect a value with content, not a null value.


Controller who detect the use of URI segments - El Forum - 09-16-2008

[eluser]Pascal Kriete[/eluser]
PHP allows for parameter defaults. Easy as pie:
Code:
function Activate($key = '')



Controller who detect the use of URI segments - El Forum - 09-17-2008

[eluser]Sein Kraft[/eluser]
Ouch, it hurts x3

Thanks for the reply inparo