Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 543683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:34:35+00:00 2026-05-13T10:34:35+00:00

Whats the recommended method for redirecting with variables in Zend Framework? Lets say we

  • 0

Whats the recommended method for redirecting with variables in Zend Framework?

Lets say we have an action like this within a controller:

 public function newAction()
    {
        $form = new Form_ApplicationForm();
        if($this->_request->isPost()){
            $data = $_POST;
            if($form->isValid($data)){
                $appModel = new Model_Application();
                $result = $appModel->createApplication($form->getValue('name'),
                    $form->getValue('email'),
                    $form->getValue('comments'));
                if($result){
                    // redirect here 
                }
            }else{
                $form->populate($data);
            }
        }
        $this->view->form = $form;
    }

If i wanted to redirect to a URL where i could show something like:

“Thanks for your application, your
reference is #123”

How should i perform this redirect?

something like this maybe?

$this->_redirect('/application/confirm/'.$result);

If so then how would i access the $result var?

EDIT OR I guess this would work:

$this->_redirect('/application/confirm/?id='.$result);

.. but i’m not sure if this is best practice or not?

I’ve seen examples where people use _forward() for their redirects but the URL never changes which creates issues with multiple submissions etc.

I’ve seen someone recommend gotoSimple() but i’m not sure about this. Still a ZF noob so apologies if this is obvious but I guess this is something with multiple uses for CRUD type systems anyway so would be interested to know.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:34:35+00:00Added an answer on May 13, 2026 at 10:34 am

    A lot of options. Your controller’s $this->_redirect() delegates the work to Zend_Controller_Action_Helper_Redirector. Check its documentation for all the options, and pick the one you like. Simplest ways not involving custom routes:

    $this->_redirect('/controller/action/param1/value1/param2/value2');
    

    or

    $this->_redirect(
        '/controller/action',
        array('param1' => 'value1', 'param2' => 'value2')
    );
    

    You’re right in paying attention to the difference between _redirect and _forward. Forwarding means just re-routing the initial request, while _redirect really causes an HTTP redirect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whats recommended in an abstract class? Have a virtual method returning null, or have
When looking to get data from a web page whats the recommended method if
I have this method and it's kind of really big so I can't include
what's the recommended method to encrypt flash files ? i'd like to make some
What would be the recommended method to create a table like display (columns, rows,
What is the recommended method for escaping variables before inserting them into the database
Lets say I have a model, Article that has a large amount of columns
I have what I presume must be a common problem. Lets say I have
What's the recommended method of accessing Plone persistent utilities and why? getToolByName(context, portal_url) direct
Whats the recommended way for storing authentication information in iOS that could be easily

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.