S
S
sugarufc2015-08-20 10:09:43
PHP
sugarufc, 2015-08-20 10:09:43

Why is the redirect not working in CakePHP?

Here is the code

class PostsController extends AppController {
    
    public $helpers = array('Html', 'Form', 'Session');
    public $components = array('Session');
    public $uses = array('Category', 'Post');
    
    public function add(){
        if($this->request->is('post')){
            $this->Post->create();
            if($this->Post->save($this->request->data)){
                $this->Session->setFlash('Статья добавлена');
                $this->redirect('/');
            }else{
                $this->Session->setFlash('Ошибка добавления статьи');
                $this->redirect('/');
            }            
        }
    }
}

when you try to redirect, a blank screen appears, I did everything as described in the documentation. What could be the reason?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LittleFatNinja, 2015-08-20
@LittleFatNinja

return $this->redirect('/');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question