views:

1673

answers:

4

I am using zend framework. I am using the following statement to redirect to another action.

$this->_helper->redirector('some_action');

Above statement is working perfectly and 'some_action' is called. Now I want to pass some parameters to 'some_action' like this.

some_action?uname=username&[email protected]

And how to get parameters in called action. Usually we do like this:

$userName = $_REQUEST['uname'];
$usermail = $_REQUEST['umail'];

How to perform this? Example code please. Thanks

+1  A: 

You may want to try this:

  $this->_redirector->gotoUrl('/my-controller/my-action/param1/test/param2/test2');
Sarfraz
+3  A: 

I use the _redirect() method (which just passes through to Sarfraz's helper method)

$this->_redirect('/module/controller/action/username/robin/email/[email protected]');

And then in the called action:

$username = $this->_getParam('username');
$email = $this->_getParam('email');

_getParam() takes a second optional argument which is set to the variable as a default if the parameter isn't found.

Robin Canaday
Perfect. It is working. Thanks
NAVEED
A: 

you can try with redirector:

$params = array('user' => $user, 'mail' => $mail);
$this->_helper->redirector($action, $controller, $module, $params);
armandfp
A: 

How do you capture that $params variable? like echo $this->params['user']; ??

lets say i do a registration and its successful executed. in my registercontroller i call:

$message="registration was a success";    
$params = array('message' => $message);
$this->_helper->redirector('index', 'login',$params);

in my loginview i want to see that success message.. How?

Please some help here

starlover
You should try to ask a question about this separately. I think using `$message= $this->_getParam('message');`
NAVEED