0

i am working on a cakephp 2.x .. right now i have a function called forgetpassword and resetpassword in my userscontroller .. i am sending an email to a user..

i am sending a url like this ..this code is written in the forgetpassword function

 $url = Router::url( array('controller'=>'users','action'=>'resetpassword'), true   ).'/'.$key.'#'.$hash;

and i receive this url in my inbox like this

https://www.myweb.com/resetpassword/y2273727372jhgdfjjd2434dff#23232323

when i click the url which is on my inbox .. it is giving me an error .. not going to the resetpassword function .. instead if i add the controller name behind the function then it successfully loading the page

e.g

 https://www.myweb.com/users/resetpassword/y2273727372jhgdfjjd2434dff#23232323

but i dont want the controller name behind the function in the url

routes.php

   Router::connect('/resetpassword', array('controller' => 'users', 'action'=>'resetpassword'));
3
  • 3
    You don't need the # part. PHP cannot use it anyway. Passed params are attached differently, thus your connect() rule is not correct, either. Try Router::connect('/resetpassword/*', ...) Commented Aug 13, 2013 at 16:24
  • so what is the correct syntax for connect... i always use use this and it works .. but this time i am stuck in quite different situation .. but whenever i want to remove the controller name i do this Commented Aug 13, 2013 at 16:27
  • @mark you should answer the question. This way helloshelkh can accept it and you guys get more rep. Commented Aug 20, 2013 at 7:52

1 Answer 1

1
Router::connect('/resetpassword', ...)

means, that you are not using anything after it as passed params etc. But you do that, so correct is:

Router::connect('/resetpassword/*', ...)

Also note that

Router::url( array('controller'=>'users','action'=>'resetpassword'), true   ).'/'.$key.'#'.$hash;

is wrong, it should be - as documented:

Router::url(
    array(
        'controller' => 'users', 
        'action' => 'resetpassword',
        $key, // passed param
        '#' => $hash // hash
    ), true);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.