Returning to same page


#1

index.ctp at “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” (in that index page) on pressing login redirected to "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

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