views:

47

answers:

2

Hi am starting off with Zend Framework and have a question about action helpers. My first application is a simple authentication system (following a tutorial from a book). The registration and authentication seems to work fine but the redirect doesn't.

I have a customer controller that has this among others:

class CustomerController extends Zend_Controller_Action 
{

// some code here......

public function authenticateAction()
{
    $request = $this->getRequest();
    if (!$request->isPost()) {
        return $this->_helper->redirector('login');
    }

    // Validate
    $form = $this->_forms['login'];
    if (!$form->isValid($request->getPost())) {
        return $this->render('login');
    }

    if (false === $this->_authService->authenticate($form->getValues())) {
        $form->setDescription('Login failed, please try again.');
        return $this->render('login');
    }

    return $this->_helper->redirector('index');
}

the authenticate url is http://localhost/customer/authenticate and this seems to work fine but it does not redirect. After authentication I get a blank page which looks like its taking me to the index and just sits there. I tried using '/index' instead but that did not help either. Do I need to do anything special to make the redirector helper work? I have a logout action which behaves the same.

A: 

You should call

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

without the return.

Goran Jurić
Nope that didn't fix it. Just tried.
jgnasser
Have you tried putting the redirector at the top of your method just to check if it works?Do you have error reporting turned on?
Goran Jurić
No it just doesnt work at all no matter where I put it.
jgnasser
A: 

I found out there may be a problem with my setup. The code above is perfect, works on another computer.

jgnasser