Is there any other command for redirecting a controller to a particular view page other than redirect and render?
I have the redirect as
$this->redirect('/forms/homepage/'.$userId);
But if I give
$this->render('/forms/homepage/'.$userId);
it doesn't get redirected to that page.
Is something wrong?
The call to redirect() issues a HTTP redirect. Nothing happens after the redirect because CakePHP simply stops. Anything you put after the redirect call will not be executed. Instead, the browser simply issues a new HTTP GET to the URL you are redirecting to.
The call to render() simply loads a view. It takes a path to a view, not an URL. It does not redirect. Assume that $userID is '101' in your case. The call to render() would try to load the following file:
app/views/forms/homepage/101.ctp
Since that file does not exist, nothing happens.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With