Reputation: 45
I am stuck with route. Here is my route.
$route['login_register'] = 'welcome/login_register';
First time I don't want to pass any extra segment.
After Login fail,I want to redirect login_register
function with failure argument in URL.
If I don't use /(:any)
,I can't access.
$this->uri->segment(2);
If i use /(:any)
,it is giving me error when first time redirecting.
$route['login_register/(:any)'] = 'welcome/login_register';
Upvotes: 2
Views: 303
Reputation: 38609
you cant do login_register
and login_register/(:any)
with same route. You can do one more thing with this.
Use one route
$route['login_register'] = 'welcome/login_register';
then inside function
public function login_register($value)
{
if (empty($value)) { # first method
echo "No argument passing";
}
else{ # second method
echo "argument is there";;
}
}
So when use passing data to controller send with /
key. Ex:
<a href="<?php echo base_url() ?>login_register"> This print first method</a>
<a href="<?php echo base_url() ?>login_register/25"> This print second method</a>
Upvotes: 2