Send data with redirect with cakePHP Version 2

0

With the redirect method, change the driver and view, but I want to change before sending a parameter, but I do not know how to receive it in the other controller, the data is sent by the url, but it is a rare thing that does not use the sign "?" but ":"

URL: link

Method that redirects to the other controller and sends the data (parameter, parameter1).

 return $this->redirect(
        array('controller' => 'Joshuas',
            'action' => 'vista',
            'parametro' => 'HolaUno',
            'parametro2' => 'Holados')
    );

they arrive at this class and thus try to receive parameters:

<?php 

class JoshuasController extends AppController {

public function vista(){
    $variable = $_GET['parametro'];
    $variable1 = $_GET['parametro1'];

}

}

But I get this error

Notice (8): Undefined index: parametro [APP\Controller\JoshuasController.php, line 6]

Notice (8): Undefined index: parameter1 [APP \ Controller \ JoshuasController.php, line 7]

    
asked by R3d3r 82 17.11.2018 в 22:05
source

1 answer

0

Try the following steps in your public function vista() :

1. Defines a parameter within the view function (a variable that receives the data it is sending through the redirect() method)

public function vista($parametro, $parametro2){
    $variable = $parametro;
    $variable1 = $parametro2;
}

2. Add the following to the end of your public function vista() :

$this->set('variable','variable1');

I hope it's your help.

    
answered by 19.11.2018 в 18:24