user3324329
user3324329

Reputation: 59

redirect to a controller function through account authentication link

I am implementing account verification through email in codeigniter, my code to send email is

$this->load->library('email');
$this->email->from('[email protected]', 'Your Name');
$this->email->to('[email protected]'); 
$this->email->subject('Email Test');
$this->email->message('
    Thanks for signing up!
    Your account has been created, click this link to activate your account
    <a href='.base_url('verify').$user_id.'/'.'1221212'.'>Your Activation Link</a>');
$this->email->send();

it is working great (user receives email), now what I want is, to redirect the user to my controller function when he clicks the link.

Function to which I want to redirect is (written using internet help)

function view_verify($id,$rand)
    {
        echo "hello";
    }

and I have added this in my routes.php in config.php (written using internet help)

$route['verify/(:any)']    = "user/view_verify/$1";

it is not working when I click the link, page not found error occurs How to sort it out?

Upvotes: 0

Views: 55

Answers (2)

Nishant
Nishant

Reputation: 3694

Just check if the function 'view_verify' is written in the controller named as 'user', if yes then try browsing the view_verify url through browser first, instead of using it directly in the mail.

your url will be

http://DOMAIN-NAME/CONTROLLER-NAME/view_verify/user_id/1221212

First check whether the above url is working or not, if its working fine then use the routes as mentioned by Kumar_v, like

$route['verify/(:any)/(:any)']    = "user/view_verify/$1/$2";

Upvotes: 1

Kumar V
Kumar V

Reputation: 8830

You are passing two parameters

Try this code.

$route['verify/(:any)/(:any)']    = "user/view_verify/$1/$2";

Upvotes: 2

Related Questions