# Returning to same page

**URL:** <https://discourse.cakephp.org/t/returning-to-same-page/2759>\
**Category:** Need Help\
**Created:** [June 21, 2017, 9:27pm UTC](https://discourse.cakephp.org/t/returning-to-same-page/2759 "2017-06-21T21:27:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![snehith](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@snehith](https://discourse.cakephp.org/u/snehith)\
**Post date:** [June 21, 2017, 9:27pm UTC](https://discourse.cakephp.org/t/returning-to-same-page/2759/1 "2017-06-21T21:27:05Z")

</div>

index.ctp at “[http://localhost:8765](http://localhost:8765)” , user details is the table to store values of users  
when I register it was redirected to “[http://localhost:8765/user-details](http://localhost:8765/user-details)” (in that index page) on pressing login redirected to "[http://localhost:8765/user-details/login](http://localhost:8765/user-details/login)"  
from this when I press register it is not going to that rather I am getting this URL and returning to the same page(login)  
“[http://localhost:8765/user-details/login?redirect=%2Fuser-details%2Fregister1](http://localhost:8765/user-details/login?redirect=%2Fuser-details%2Fregister1)”

here is my route.php

\<?php use Cake\Core\Plugin; use Cake\Routing\RouteBuilder; use Cake\Routing\Router; use Cake\Routing\Route\DashedRoute; Router::defaultRouteClass(DashedRoute::class); Router::scope('/', function (RouteBuilder $routes) { $routes-\>connect('/', ['controller' =\> 'Pages', 'action' =\> 'display', 'index']); $routes-\>connect('/pages/\*', ['controller' =\> 'Pages', 'action' =\> 'display']); $routes-\>connect('/userDetails/\*', ['controller' =\> 'Pages', 'action' =\> 'display',]); $routes-\>fallbacks(DashedRoute::class); }); Plugin::routes(); my userdetails controller: public function register1() { $this-\>render('/Pages/register1.ctp'); } public function register2() { $this-\>render('/Pages/register2.ctp'); } public function register() { $userDetail = $this-\>UserDetails-\>newEntity(); if ($this-\>request-\>is('post')) { $userDetail = $this-\>UserDetails-\>patchEntity($userDetail, $this-\>request-\>getData()); if ($this-\>UserDetails-\>save($userDetail)) { $this-\>Flash-\>success(\_\_('The user detail has been saved.')); return $this-\>redirect(['action' =\> 'index']); } $this-\>Flash-\>error(\_\_('The user detail could not be saved. Please, try again.')); } $this-\>set(compact('userDetail')); $this-\>set('\_serialize', ['userDetail']); } I have written that register1, iregister2 as it was showing error if not declared and my register linking part: - \<?= $this-\>Html-\>link(\_\_('Login'), ['action' =\> 'login']) ?\>

```
	 <li><?= $this->Html->link(__('Register'), ['action' => 'register1']) ?></li>
	 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutor <b class="caret"></b></a>
	  <ul class="dropdown-menu">
	   <li><?= $this->Html->link(__('Login'), ['action' => 'login']) ?></li>
	   <li><?= $this->Html->link(__('Register'), ['action' => 'register2']) ?></li>
	  </ul>

```

and I have register1,index,register2.ctp files in userdetails folder
