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 6613857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:16:06+00:00 2026-05-25T20:16:06+00:00

For some reason my zend application is redirecting when it’s not supposed to. The

  • 0

For some reason my zend application is redirecting when it’s not supposed to.

The index view just shows the form. The next view shows some information from a database based on the information supplied by the form. The user then clicks on a confirm button which sends them to anotherAction which constructs and sends an email. I’ve got a try/catch block where it tries to send the email. If successful, set one variable, otherwise set another.

Psudo-code:

public function indexAction()
{
 $form = new Form();
 if(!empty($_POST))
 {
  if($form->isValid($_POST))
  {
   $this->_helper->FlashMessenger($_POST); //store $_POST in temporary session
   //show a different view
   //do something else
  }
 }
$this->view->form = $form;
}

So I’m instantialising a form, if the user posts the form then validate it and store the session variables in a flash session and show a differnet view. In all cases show the form (if it has been sent then it will be auto-populated).

public function anotherAction()
{
 $messages = $this->_helper->FlashMessenger->getMessages();
 if (!empty($messages[0]))
 {
  $post = $messages[0];
  $mail = new My_Mail();
  //set up email
  try
  {
   $mail->send();
   $success = true;
  }
  catch (Zend_Exception $e)
  {
   $success=false;
   //save $e to log
  }
  $this->view->success = $success;
 }
 else
 {
  //if not sent here by /page, then redirect to it.
  $this->_helper->redirector->goToRouteAndExit(array(), 'page', true);
 }
}

In this action, I’m checking for the session. If it’s got the form data in it, then try to send an email and set variable; otherwise redirect back to the form. The view variable is used to show one message or the other (email sent / email failed to send).

Here’s the problem: It redirects back to the form anyway. The form is submitted and confirmed, we go to the next page where it does something then it redirects back to the page with the form on it. Why is it doing this and how do I stop it?

[edit]
The plot thickens: If I open the confirm link in a new tab it will run and stop correctly. If I do it in the same tab/window it runs twice and redirects.

[another edit]
I have removed all the code in the second action.
The code is now:

public function anotherAction()
{
 $messages = $this->_helper->FlashMessenger->getMessages();
 if (!empty($messages[0]))
 {
  ;
 }
 else
 {
  $this->_helper->redirector->goToRouteAndExit(array(), 'page', true);
 }
}

and it is still redirecting.

For the confirm button I have

<a href="next-page"><button>Confirm</button></a>

Could the anchor and button both be calling the next-page?

[final edit]
Ok, this IS the problem. It looks like both the button and the anchor are calling the page! So the first time it runs it’s ok then it runs again and redirects me 🙁

Well, there we go. Learn something new everyday.

Thanks for the help all.

  • 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-25T20:16:07+00:00Added an answer on May 25, 2026 at 8:16 pm

    Both the button and the anchor are calling the page! So the first time it runs it’s ok then it runs again and redirects me.

    Removed the button.

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

Sidebar

Related Questions

For some reason I never see this done. Is there a reason why not?
For some reason, Section 1 works but Section 2 does not. When run in
Hi guys for some weird reason I'm unable to send email using zend mail
I'm using Zend_Validate to validate some form input (Zend Framework version is 1.8.2). For
I am working on a Zend Framework application with PHP. I have a form
Using Zend _gdata. For some reason, recently the $when string is no longer utf-8.
I'm currently building a web application (utilizing Zend Framework) and have gotten some of
I'm drawing a blank for some reason on how to access this information in
For some reason the LoadContent method does not get called in my Components. For
For some reason when I attempt to make a request to an Ajax.net web

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.