Answer the question
In order to leave comments, you need to log in
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('/');
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question